use of com.generallycloud.baseio.component.UnsafeSocketSession in project baseio by generallycloud.
the class ClientHttpFuture method updateWebSocketProtocol.
@Override
public void updateWebSocketProtocol() {
ChannelConnector connector = (ChannelConnector) context.getChannelService();
UnsafeSocketSession session = (UnsafeSocketSession) connector.getSession();
SocketChannel channel = session.getSocketChannel();
channel.setProtocolFactory(WebSocketProtocolFactory.WS_PROTOCOL_FACTORY);
channel.setProtocolDecoder(WebSocketProtocolFactory.WS_PROTOCOL_DECODER);
channel.setProtocolEncoder(WebSocketProtocolFactory.WS_PROTOCOL_ENCODER);
}
use of com.generallycloud.baseio.component.UnsafeSocketSession in project baseio by generallycloud.
the class AioSocketChannelConnector method connect.
@Override
protected void connect(InetSocketAddress socketAddress) throws IOException {
AsynchronousChannelGroup group = context.getAsynchronousChannelGroup();
final AsynchronousSocketChannel _channel = AsynchronousSocketChannel.open(group);
_channel.connect(socketAddress, this, new CompletionHandler<Void, AioSocketChannelConnector>() {
@Override
public void completed(Void result, AioSocketChannelConnector connector) {
CachedAioThread aioThread = (CachedAioThread) Thread.currentThread();
AioSocketChannel channel = new AioSocketChannel(aioThread, _channel, 1);
connector.finishConnect(channel.getSession(), null);
aioThread.getReadCompletionHandler().completed(0, channel);
}
@Override
public void failed(Throwable exc, AioSocketChannelConnector connector) {
connector.finishConnect((UnsafeSocketSession) getSession(), exc);
}
});
wait4connect();
}
Aggregations