private void handleAcceptedSocket(ChannelEvent element) {
if (element instanceof ChannelStateEvent) {
ChannelStateEvent event = (ChannelStateEvent) element;
OioAcceptedSocketChannel channel =
(OioAcceptedSocketChannel) event.getChannel();
ChannelFuture future = event.getFuture();
ChannelState state = event.getState();
Object value = event.getValue();
switch (state) {
case OPEN:
if (Boolean.FALSE.equals(value)) {
OioWorker.close(channel, future);
}
break;
case BOUND:
case CONNECTED:
if (value == null) {
OioWorker.close(channel, future);
}
break;
case INTEREST_OPS:
OioWorker.setInterestOps(channel, future, ((Integer) value).intValue());
break;
}
} else if (element instanceof MessageEvent) {
MessageEvent event = (MessageEvent) element;
OioSocketChannel channel = (OioSocketChannel) event.getChannel();
ChannelFuture future = event.getFuture();
Object message = event.getMessage();
OioWorker.write(channel, future, message);
}
}