@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
Object message = e.getMessage();
if (message instanceof GameEvent) {
GameEvent gameEvent = (GameEvent) message;
ClientWriteThread writeThread = channels.get(gameEvent.getSource());
if (writeThread == null) {
synchronized (clients) {
for (int i = 0; i < clients.size(); i++) {
if (clients.get(i).getChannel() == ctx.getChannel()) {
channels.put(gameEvent.getSource(), clients.get(i));
clients.remove(i);
break;
}
}
}