private void OnHandshakeComplete(ProtocolStack protocolStack, SocketChannel channel, Exception failure) { if (failure != null) { _log.error("Error when negotiating protocol stack", failure); return; } try { _protocolInstallerRepository.installerFor(protocolStack).install(channel); channel.parent().pipeline().fireUserEventTriggered(new ServerHandshakeFinishedEvent_Created(ToSocketAddress(channel), protocolStack)); } catch (Exception t) { _log.error("Error installing protocol stack", t); } }
private NettyHandshakeServer CreateHandshakeServer(SocketChannel channel) { HandshakeServer handshakeServer = new HandshakeServer(_applicationProtocolRepository, _modifierProtocolRepository, new SimpleNettyChannel(channel, _log) ); handshakeServer.ProtocolStackFuture().whenComplete((protocolStack, failure) => onHandshakeComplete(protocolStack, channel, failure)); channel.closeFuture().addListener(f => { try { channel.parent().pipeline().fireUserEventTriggered(new ServerHandshakeFinishedEvent_Closed(ToSocketAddress(channel))); } catch (RejectedExecutionException) { } }); return(new NettyHandshakeServer(handshakeServer)); }