/** * 处理向客户发送数据 * * @param key SelectionKey */ public void write(SelectionKey key) { try { SocketChannel sc = (SocketChannel) key.channel(); Response response = new Response(sc); // 触发onWrite事件 notifier.fireOnWrite((Request) key.attachment(), response); AppServer.processReadRequest(key); } catch (Exception e) { key.cancel(); notifier.fireOnError("Error occured in Writer: " + e); } }