protected void handleClient(SelectionKey key) throws IOException {
   SocketChannel sc = (SocketChannel) key.channel();
   ClientInfo ci = (ClientInfo) allClients.get(sc);
   if (ci == null) throw new IllegalStateException("Unknown client");
   if (key.isWritable()) send(sc, ci);
   if (key.isReadable())
     // 从一个客户端读进所有的可用数据
     recv(sc, ci);
 }
 protected void registeredClient(SocketChannel sc) throws IOException {
   ClientInfo ci = new ClientInfo();
   ci.channel = sc;
   ci.outBuf.clear();
   ci.outBuf.put(TypeServerConstants.WELCOME);
   ci.outBuf.flip();
   allClients.put(sc, ci);
   send(sc, ci);
 }