本文整理汇总了Java中com.koushikdutta.async.future.Cancellable类的典型用法代码示例。如果您正苦于以下问题:Java Cancellable类的具体用法?Java Cancellable怎么用?Java Cancellable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cancellable类属于com.koushikdutta.async.future包,在下文中一共展示了Cancellable类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: nextConnection
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
private void nextConnection(AsyncHttpRequest request) {
Uri uri = request.getUri();
final int port = getSchemePort(uri);
String key = computeLookup(uri, port, request.getProxyHost(), request.getProxyPort());
synchronized (AsyncSocketMiddleware.this) {
ConnectionInfo info = connectionInfo.get(key);
if (info == null)
return;
--info.openCount;
while (info.openCount < maxConnectionCount && info.queue.size() > 0) {
GetSocketData gsd = info.queue.remove();
SimpleCancellable socketCancellable = (SimpleCancellable)gsd.socketCancellable;
if (socketCancellable.isCancelled())
continue;
Cancellable connect = getSocket(gsd);
socketCancellable.setParent(connect);
}
maybeCleanupConnectionInfo(key);
}
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:21,代码来源:AsyncSocketMiddleware.java
示例2: connectSocket
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
public Cancellable connectSocket(final InetSocketAddress remote, final ConnectCallback callback) {
if (!remote.isUnresolved())
return connectResolvedInetSocketAddress(remote, callback);
final SimpleFuture<AsyncNetworkSocket> ret = new SimpleFuture<AsyncNetworkSocket>();
Future<InetAddress> lookup = getByName(remote.getHostName());
ret.setParent(lookup);
lookup
.setCallback(new FutureCallback<InetAddress>() {
@Override
public void onCompleted(Exception e, InetAddress result) {
if (e != null) {
callback.onConnectCompleted(e, null);
ret.setComplete(e);
return;
}
ret.setComplete(connectResolvedInetSocketAddress(new InetSocketAddress(result, remote.getPort()), callback));
}
});
return ret;
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:24,代码来源:AsyncServer.java
示例3: websocket
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
public Future<WebSocket> websocket(final AsyncHttpRequest req, String protocol, final WebSocketConnectCallback callback) {
WebSocketImpl.addWebSocketUpgradeHeaders(req, protocol);
final SimpleFuture<WebSocket> ret = new SimpleFuture<WebSocket>();
Cancellable connect = execute(req, new HttpConnectCallback() {
@Override
public void onConnectCompleted(Exception ex, AsyncHttpResponse response) {
if (ex != null) {
if (ret.setComplete(ex)) {
if (callback != null)
callback.onCompleted(ex, null);
}
return;
}
WebSocket ws = WebSocketImpl.finishHandshake(req.getHeaders(), response);
if (ws == null) {
ex = new WebSocketHandshakeException("Unable to complete websocket handshake");
if (!ret.setComplete(ex))
return;
}
else {
if (!ret.setComplete(ws))
return;
}
if (callback != null)
callback.onCompleted(ex, ws);
}
});
ret.setParent(connect);
return ret;
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:32,代码来源:AsyncHttpClient.java
示例4: websocket
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
public Future<WebSocket> websocket(final AsyncHttpRequest req, String protocol, final WebSocketConnectCallback callback) {
WebSocketImpl.addWebSocketUpgradeHeaders(req, protocol);
final SimpleFuture<WebSocket> ret = new SimpleFuture<WebSocket>();
Cancellable connect = execute(req, new HttpConnectCallback() {
@Override
public void onConnectCompleted(Exception ex, AsyncHttpResponse response) {
if (ex != null) {
if (ret.setComplete(ex)) {
if (callback != null)
callback.onCompleted(ex, null);
}
return;
}
WebSocket ws = WebSocketImpl.finishHandshake(req.getHeaders(), response);
if (ws == null) {
if (!ret.setComplete(new WebSocketHandshakeException("Unable to complete websocket handshake")))
return;
}
else {
if (!ret.setComplete(ws))
return;
}
if (callback != null)
callback.onCompleted(ex, ws);
}
});
ret.setParent(connect);
return ret;
}
开发者ID:BeckNiu,项目名称:MyCar,代码行数:31,代码来源:AsyncHttpClient.java
示例5: websocket
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
public Future<WebSocket> websocket(final AsyncHttpRequest req, String protocol, final WebSocketConnectCallback callback) {
WebSocketImpl.addWebSocketUpgradeHeaders(req, protocol);
final SimpleFuture<WebSocket> ret = new SimpleFuture<WebSocket>();
Cancellable connect = execute(req, new HttpConnectCallback() {
@Override
public void onConnectCompleted(Exception ex, AsyncHttpResponse response) {
if (ex != null) {
if (ret.setComplete(ex)) {
if (callback != null)
callback.onCompleted(ex, null);
}
return;
}
WebSocket ws = WebSocketImpl.finishHandshake(req.getHeaders().getHeaders(), response);
if (ws == null) {
if (!ret.setComplete(new Exception("Unable to complete websocket handshake")))
return;
}
else {
if (!ret.setComplete(ws))
return;
}
if (callback != null)
callback.onCompleted(ex, ws);
}
});
ret.setParent(connect);
return ret;
}
开发者ID:xiaoshutong,项目名称:AndroidNio,代码行数:31,代码来源:AsyncHttpClient.java
示例6: connectSocket
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
public Cancellable connectSocket(final InetSocketAddress remote, final ConnectCallback callback) {
if (!remote.isUnresolved())
return connectResolvedInetSocketAddress(remote, callback);
return new TransformFuture<AsyncSocket, InetAddress>() {
@Override
protected void transform(InetAddress result) throws Exception {
setParent(connectResolvedInetSocketAddress(new InetSocketAddress(remote.getHostName(), remote.getPort()), callback));
}
}.from(getByName(remote.getHostName()));
}
开发者ID:xiaoshutong,项目名称:AndroidNio,代码行数:12,代码来源:AsyncServer.java
示例7: getSocket
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
@Override
public Cancellable getSocket(GetSocketData data) {
return null;
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:5,代码来源:SimpleMiddleware.java
示例8: multicastLookup
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
public static Cancellable multicastLookup(AsyncServer server, String host, FutureCallback<DnsResponse> callback) {
return lookup(server, host, true, callback);
}
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:4,代码来源:Dns.java
示例9: getSocket
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
/**
* Called to retrieve the socket that will fulfill this request
* @param data
* @return
*/
public Cancellable getSocket(GetSocketData data);
开发者ID:jacklongway,项目名称:LiteSDK,代码行数:7,代码来源:AsyncHttpClientMiddleware.java
示例10: getSocket
import com.koushikdutta.async.future.Cancellable; //导入依赖的package包/类
public Cancellable getSocket(GetSocketData data);
开发者ID:xiaoshutong,项目名称:AndroidNio,代码行数:2,代码来源:AsyncHttpClientMiddleware.java
注:本文中的com.koushikdutta.async.future.Cancellable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论