final SelectionKey key = it.next(); final SelectorListener listener = (SelectorListener) key.attachment(); logger.debug("key : {}", key); int ops = key.readyOps(); boolean isAcceptable = (ops & SelectionKey.OP_ACCEPT) == SelectionKey.OP_ACCEPT; boolean isConnectable = (ops & SelectionKey.OP_CONNECT) == SelectionKey.OP_CONNECT; boolean isReadable = (ops & SelectionKey.OP_READ) == SelectionKey.OP_READ; boolean isWritable = (ops & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE; listener.ready(isAcceptable, isConnectable, isReadable, isReadable ? readBuffer : null, isWritable); // if you don't remove the event of the set, the selector will present you this event again and // again logger.debug("remove"); it.remove();
|