Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.zazof.jteg
Class MessageManager  view MessageManager download MessageManager.java

java.lang.Object
  extended byorg.zazof.jteg.MessageManager
All Implemented Interfaces:
java.lang.Runnable

public class MessageManager
extends java.lang.Object
implements java.lang.Runnable

This class is responsible for:

Ideally, only this class should have contact with the TEGServer
Implements the Singleton pattern.


Field Summary
private  MessageChainBuilder $builder
           
private  boolean $connected
           
private  java.lang.Thread $currentThread
           
private  Message $entryPoint
           
private  boolean $isRunning
           
private  TEGServer $server
           
private static boolean DEBUG
           
private static MessageManager instance
           
private  java.util.Vector listeners
           
 
Constructor Summary
private MessageManager()
           
 
Method Summary
 void addMessageListener(MessageListener ml)
           
 void askPlayerStatus()
          This method will ask the playerstatus to the server.
 void broadCastInternalMessage(java.lang.String[] messageParts)
          This method will broadcast a specific message to all those interested in an InformationMessage This method may be used for reducing coupling between domain & GUI layer.
private  Message decodeMessage(java.lang.String message)
           
 void disconnect()
          Disconnect from the server, if we are connected.
static MessageManager getInstance()
           
private  void init()
           
 void makeConnectionWithServer(java.lang.String server, int port)
          Makes the actual connection with server on the specified port.
 void notifyAllListeners(Message m)
           
 void removeMessageListener(MessageListener ml)
           
 void run()
          This method will be called by whoever wishes to run your class implementing Runnable.
 void sendToServer(java.lang.String[] messageParts)
          This method will build the correct messagestring to the server based on the 'parts' that are supplied as a parameter in a StringArray.
 void startThread()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listeners

private java.util.Vector listeners

instance

private static MessageManager instance

$currentThread

private java.lang.Thread $currentThread

$isRunning

private boolean $isRunning

$connected

private boolean $connected

$entryPoint

private Message $entryPoint

$builder

private MessageChainBuilder $builder

DEBUG

private static boolean DEBUG

$server

private TEGServer $server
Constructor Detail

MessageManager

private MessageManager()
Method Detail

getInstance

public static MessageManager getInstance()

startThread

public void startThread()

run

public void run()
Description copied from interface: java.lang.Runnable
This method will be called by whoever wishes to run your class implementing Runnable. Note that there are no restrictions on what you are allowed to do in the run method, except that you cannot throw a checked exception.

Specified by:
run in interface java.lang.Runnable

addMessageListener

public void addMessageListener(MessageListener ml)

removeMessageListener

public void removeMessageListener(MessageListener ml)

notifyAllListeners

public void notifyAllListeners(Message m)

makeConnectionWithServer

public void makeConnectionWithServer(java.lang.String server,
                                     int port)
                              throws java.io.IOException,
                                     ServerException
Makes the actual connection with server on the specified port. Before sending any message to the TEG server, this method should be called.


disconnect

public void disconnect()
Disconnect from the server, if we are connected. Otherwise, nothing happens.


sendToServer

public void sendToServer(java.lang.String[] messageParts)
                  throws UnknownMessageException,
                         ServerException
This method will build the correct messagestring to the server based on the 'parts' that are supplied as a parameter in a StringArray. It will then send this message to the server.


broadCastInternalMessage

public void broadCastInternalMessage(java.lang.String[] messageParts)
                              throws UnknownMessageException
This method will broadcast a specific message to all those interested in an InformationMessage This method may be used for reducing coupling between domain & GUI layer.


askPlayerStatus

public void askPlayerStatus()
                     throws ServerException
This method will ask the playerstatus to the server.


decodeMessage

private Message decodeMessage(java.lang.String message)
                       throws UnknownMessageException

init

private void init()