private void handleKey(Selector selector, SelectionKey key) throws IOException { if (key.isValid() && key.isAcceptable()) { // Accept a new connection, give it a stream connection as an attachment SocketChannel newChannel = sc.accept(); newChannel.configureBlocking(false); SelectionKey newKey = newChannel.register(selector, SelectionKey.OP_READ); try { ConnectionHandler handler = new ConnectionHandler(connectionFactory, newKey); newKey.attach(handler); handler.connection.connectionOpened(); } catch (IOException e) { // This can happen if ConnectionHandler's call to get a new handler returned null log.error("Error handling new connection", Throwables.getRootCause(e).getMessage()); newKey.channel().close(); } } else { // Got a closing channel or a channel to a client connection ConnectionHandler.handleKey(key); } }
private void handleKey(Selector selector, SelectionKey key) throws IOException { if (key.isValid() && key.isAcceptable()) { // Accept a new connection, give it a stream connection as an attachment SocketChannel newChannel = sc.accept(); newChannel.configureBlocking(false); SelectionKey newKey = newChannel.register(selector, SelectionKey.OP_READ); try { ConnectionHandler handler = new ConnectionHandler(connectionFactory, newKey); newKey.attach(handler); handler.connection.connectionOpened(); } catch (IOException e) { // This can happen if ConnectionHandler's call to get a new handler returned null log.error("Error handling new connection", Throwables.getRootCause(e).getMessage()); newKey.channel().close(); } } else { // Got a closing channel or a channel to a client connection ConnectionHandler.handleKey(key); } }
private void handleKey(Selector selector, SelectionKey key) throws IOException { if (key.isValid() && key.isAcceptable()) { // Accept a new connection, give it a stream connection as an attachment SocketChannel newChannel = sc.accept(); newChannel.configureBlocking(false); SelectionKey newKey = newChannel.register(selector, SelectionKey.OP_READ); try { ConnectionHandler handler = new ConnectionHandler(connectionFactory, newKey); newKey.attach(handler); handler.connection.connectionOpened(); } catch (IOException e) { // This can happen if ConnectionHandler's call to get a new handler returned null log.error("Error handling new connection", Throwables.getRootCause(e).getMessage()); newKey.channel().close(); } } else { // Got a closing channel or a channel to a client connection ConnectionHandler.handleKey(key); } }
private void handleKey(Selector selector, SelectionKey key) throws IOException { if (key.isValid() && key.isAcceptable()) { // Accept a new connection, give it a stream connection as an attachment SocketChannel newChannel = sc.accept(); newChannel.configureBlocking(false); SelectionKey newKey = newChannel.register(selector, SelectionKey.OP_READ); try { ConnectionHandler handler = new ConnectionHandler(connectionFactory, newKey); newKey.attach(handler); handler.connection.connectionOpened(); } catch (IOException e) { // This can happen if ConnectionHandler's call to get a new handler returned null log.error("Error handling new connection", Throwables.getRootCause(e).getMessage()); newKey.channel().close(); } } else { // Got a closing channel or a channel to a client connection ConnectionHandler.handleKey(key); } }
StreamConnection connection = data.connection; SocketChannel sc = (SocketChannel) key.channel(); ConnectionHandler handler = new ConnectionHandler(connection, key, connectedHandlers); try { if (sc.finishConnect()) {
StreamConnection connection = data.connection; SocketChannel sc = (SocketChannel) key.channel(); ConnectionHandler handler = new ConnectionHandler(connection, key, connectedHandlers); try { if (sc.finishConnect()) {
StreamConnection connection = data.connection; SocketChannel sc = (SocketChannel) key.channel(); ConnectionHandler handler = new ConnectionHandler(connection, key, connectedHandlers); try { if (sc.finishConnect()) {
StreamConnection connection = data.connection; SocketChannel sc = (SocketChannel) key.channel(); ConnectionHandler handler = new ConnectionHandler(connection, key, connectedHandlers); try { if (sc.finishConnect()) {