cz.cuni.pogamut.Parser
Class GameBotConnection

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

public class GameBotConnection
extends java.lang.Object

Merely a wrapper for the GameBots2004 socket, which implements sending, closing and handling exceptions.


Nested Class Summary
private  class GameBotConnection.BufferedReaderForLog
          This class is used to dump the raw data from GameBots.
 
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.BufferedReader input
           
private  java.util.logging.Logger log
           
private  java.io.PrintWriter output
           
private  java.util.logging.Logger rawDataLog
           
private  GameBotConnection.BufferedReaderForLog readerForLog
           
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
           
static int SOCKET_TIMEOUT
           
 
Constructor Summary
GameBotConnection()
          Inicialize class.
GameBotConnection(java.lang.String netAddress)
          Inicialize class.
GameBotConnection(java.lang.String netAddress, int port)
          Inicialize class.
GameBotConnection(java.lang.String netAddress, int port, java.util.logging.Logger log)
          Inicialize class.
GameBotConnection(java.lang.String netAddress, int port, java.util.logging.Logger log, java.util.logging.Logger rawDataLog)
          Inicialize class.
GameBotConnection(java.lang.String netAddress, java.util.logging.Logger rawDataLog)
          Inicialize class.
 
Method Summary
 void close()
          Clean up stuff.
 void connect()
          Connect to Unreal Server with installed GameBot using parametr from constructor.
 java.util.logging.Logger getRawDataLog()
           
 boolean isConnected()
          Is class connected to GameBots?
 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

SOCKET_TIMEOUT

public static final int SOCKET_TIMEOUT
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.BufferedReader input

output

private java.io.PrintWriter output

log

private java.util.logging.Logger log

rawDataLog

private java.util.logging.Logger rawDataLog

readerForLog

private GameBotConnection.BufferedReaderForLog readerForLog
Constructor Detail

GameBotConnection

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

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

GameBotConnection

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

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

GameBotConnection

public GameBotConnection(java.lang.String netAddress,
                         int port)
                  throws java.net.UnknownHostException
Inicialize class.

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

GameBotConnection

public GameBotConnection(java.lang.String netAddress)
                  throws java.net.UnknownHostException
Inicialize class. Port of GameBots 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

GameBotConnection

public GameBotConnection(java.lang.String netAddress,
                         java.util.logging.Logger rawDataLog)
                  throws java.net.UnknownHostException
Inicialize class. Port of GameBots 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

GameBotConnection

public GameBotConnection()
                  throws java.net.UnknownHostException
Inicialize class. Assume that UT2004 server with gameBots is running at localhost:3000 and creating own log.

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

getRawDataLog

public java.util.logging.Logger getRawDataLog()

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

close

public void close()
           throws CantCloseConnectionException
Clean up stuff. Close socket for gamebot, close streams for communication.

Throws:
CantCloseConnectionException

isConnected

public boolean isConnected()
Is class connected to GameBots?

Returns:
true - connection is established, else false

send

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