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

Quick Search    Search Deep

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

java.lang.Object
  extended byorg.zazof.jteg.TEGServer

public class TEGServer
extends java.lang.Object

This class servers as a TEG server proxy. All communication with the TEG server passes via this class. Implements the singleton pattern. This class contains methods for each message that can be send to the TEG server. The real connection with the server is encapsulated in a Connection object.


Field Summary
private  Connection $currentConnection
           
private static int $protocolVersion
           
private static java.lang.String $serverVersion
           
private static boolean DEBUG
           
 
Constructor Summary
(package private) TEGServer()
          Constructor of TEG server
 
Method Summary
 void disconnect()
          Disconnect from the server.
 java.lang.String getMessageFromServer()
          Gets a message from the TEGServer in Stringformat.
 int getProtocolVersion()
          Returns the protocol currently in use by Jteg.
 java.lang.String getServerVersion()
          Returns a description of the server we are currently connected to.
 void makeConnectionWithServer(java.lang.String server, int port)
          Makes the actual connection with server on the specified port.
Before sending any message to the TEG server, this method should be called.
 void send(java.lang.String message, java.lang.String errorMessage)
          Sends a message to the TEGServer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

$currentConnection

private Connection $currentConnection

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

$protocolVersion

private static int $protocolVersion

$serverVersion

private static java.lang.String $serverVersion
Constructor Detail

TEGServer

TEGServer()
Constructor of TEG server

Method Detail

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. This method is also responsible for implementing the handshake and identifying the protocolversion of the TEGServer.


disconnect

public void disconnect()
Disconnect from the server.
If no connection is currently open, nothing happens.


send

public void send(java.lang.String message,
                 java.lang.String errorMessage)
          throws ServerException
Sends a message to the TEGServer.


getMessageFromServer

public java.lang.String getMessageFromServer()
                                      throws java.io.IOException,
                                             ServerException
Gets a message from the TEGServer in Stringformat.
Since this message is not yet interpreted, the method should normally only be called by the MessageManager. This method blocks the calling thread if no messages are available!


getProtocolVersion

public int getProtocolVersion()
                       throws ServerException
Returns the protocol currently in use by Jteg.
Tegservers upto 0.7 use protocol 3, 0.8.x use protocol 4, 0.9.x use protocol 5 etc...


getServerVersion

public java.lang.String getServerVersion()
                                  throws ServerException
Returns a description of the server we are currently connected to.