cz.cuni.pogamut.Parser
Class ParserConnection

java.lang.Object
  extended by cz.cuni.pogamut.Parser.ParserConnection

public class ParserConnection
extends java.lang.Object

Wrapper for the socket to the Remote Parser. User by Client when the Remote Parser is requested.


Field Summary
static java.lang.String DEFAULT_ADDRESS
          Default address for connection ... localhost
static int DEFAULT_PORT
          Default port for connection ... localhost
protected  java.io.ObjectInputStream input
           
private  java.util.logging.Logger log
           
private  java.io.PrintWriter output
           
protected  java.net.InetAddress serverAddress
          InetAddress used by the connection (remote side)
protected  int serverPort
          Remote port of the connection.
private  java.net.Socket socket
           
 
Constructor Summary
ParserConnection()
          Inicialize class.
ParserConnection(java.lang.String netAddress)
          Inicialize class.
ParserConnection(java.lang.String netAddress, int port, java.util.logging.Logger log)
          Inicialize class.
 
Method Summary
 void close()
           
 void connect()
          Connect to Unreal Server with installed GameBot using parametr from constructor.
(package private)  void disconnect()
          Clean up stuff.
 boolean isConnected()
          Is class connected to RemoteParser?
 MessageObject readObject()
           
 void send(java.lang.String msg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ADDRESS

public static final java.lang.String DEFAULT_ADDRESS
Default address for connection ... localhost

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
Default port for connection ... localhost

See Also:
Constant Field Values

serverAddress

protected java.net.InetAddress serverAddress
InetAddress used by the connection (remote side)


serverPort

protected int serverPort
Remote port of the connection.


socket

private java.net.Socket socket

input

protected java.io.ObjectInputStream input

output

private java.io.PrintWriter output

log

private java.util.logging.Logger log
Constructor Detail

ParserConnection

public ParserConnection(java.lang.String netAddress,
                        int port,
                        java.util.logging.Logger log)
                 throws java.net.UnknownHostException
Inicialize class.

Parameters:
netAddress - network address, where is running the RemoteParser
port - port, where RemoteParser listens
Throws:
java.net.UnknownHostException - if passed hostname/ip address doesnt exists, throw exception

ParserConnection

public ParserConnection(java.lang.String netAddress)
                 throws java.net.UnknownHostException
Inicialize class. Port of RemoteParser is assumed to be 3000 and creating own log.

Parameters:
netAddress - network address, where is running UT2004 server with GameBots
Throws:
java.net.UnknownHostException - if passed hostname/ip address doesnt exists, throw exception

ParserConnection

public ParserConnection()
                 throws java.net.UnknownHostException
Inicialize class. Assume that RemoteParser is running at localhost:4000 and creating own log.

Throws:
java.net.UnknownHostException - if passed hostname/ip address doesnt exists, throw exception
Method Detail

connect

public void connect()
             throws ConnectException
Connect to Unreal Server with installed GameBot using parametr from constructor.

Throws:
ConnectException
If - socket can't be created, throw IOException

disconnect

void disconnect()
          throws DisconnectException
Clean up stuff. Close socket for remote parser, close streams for communication.

Throws:
DisconnectException

isConnected

public boolean isConnected()
Is class connected to RemoteParser?

Returns:
true - connection is established, else false

send

public void send(java.lang.String msg)
          throws CantWriteException
Throws:
CantWriteException

readObject

public MessageObject readObject()
                         throws CantReadException
Throws:
CantReadException

close

public void close()
           throws CantCloseConnectionException
Throws:
CantCloseConnectionException