Package handlers.chat

Source Code of handlers.chat.PostMessageHandler

package handlers.chat;


import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import main.Config;

import connection.ClientConnection;
import handlers.AbstractServerHandler;
import iteration.ConnectionIterationClientInterface;
import iteration.context.IterationContextInterface;
import iteration.context.ChatMessageContext;

import static main.ServerMain.getConnectionManager;


public class PostMessageHandler extends AbstractServerHandler implements
    ConnectionIterationClientInterface
{
  public void execute(ClientConnection connection, ObjectInputStream is,
      ObjectOutputStream os) throws IOException, ClassNotFoundException
  {
    String message = is.readUTF();
    if (Config.server.enableChat)
    {
      getConnectionManager().iterate(this,
          new ChatMessageContext(connection.getNickname(), message));
    }
  }

  public void iterate(ClientConnection currentClient, IterationContextInterface context)
  {
    ChatMessageContext customContext = context.queryPostMessageHandlerContext();
    currentClient.sendChatMessage(customContext.getSenderName(), customContext
        .getMessage());
  }

}
TOP

Related Classes of handlers.chat.PostMessageHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.