cz.cuni.pogamut.communication
Class MediatorForClient

java.lang.Object
  extended by cz.cuni.pogamut.communication.MediatorForClient
All Implemented Interfaces:
MediatorClientInterface

public class MediatorForClient
extends java.lang.Object
implements MediatorClientInterface

This class stands between Client and Mediator, used by RemoteParser when creating new Mediator.


Field Summary
private  java.net.Socket clientSocket
          Socket to the Client.
protected  java.io.BufferedReader input
          Used to read messages from the Client, which should be delivered to the GameBots.
private  java.util.concurrent.BlockingQueue<MessageObject> messagesForClient
           
private  java.io.ObjectOutputStream output
          Used for sending messages to the Client.
 
Constructor Summary
MediatorForClient(java.net.Socket clientSocket)
           
 
Method Summary
 void closeClient()
          Closes the client's socket.
 java.lang.String receiveMessageFromClient()
          Reads message from the Client (command to the GameBots).
 void sendMessageToClient(MessageObject msg)
          Sends parsed message from the Parser to the Client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messagesForClient

private java.util.concurrent.BlockingQueue<MessageObject> messagesForClient

clientSocket

private java.net.Socket clientSocket
Socket to the Client.


input

protected java.io.BufferedReader input
Used to read messages from the Client, which should be delivered to the GameBots.


output

private java.io.ObjectOutputStream output
Used for sending messages to the Client.

Constructor Detail

MediatorForClient

public MediatorForClient(java.net.Socket clientSocket)
                  throws java.io.IOException
Throws:
java.io.IOException
Method Detail

receiveMessageFromClient

public java.lang.String receiveMessageFromClient()
                                          throws CantReadException
Reads message from the Client (command to the GameBots). May block.

Specified by:
receiveMessageFromClient in interface MediatorClientInterface
Throws:
CantReadException

sendMessageToClient

public void sendMessageToClient(MessageObject msg)
                         throws CantWriteException
Sends parsed message from the Parser to the Client.

Specified by:
sendMessageToClient in interface MediatorClientInterface
Throws:
CantWriteException

closeClient

public void closeClient()
                 throws CantCloseConnectionException
Closes the client's socket.

Specified by:
closeClient in interface MediatorClientInterface
Throws:
CantCloseConnectionException