aigames.soccer.observer
Class Communication

java.lang.Object
  extended byaigames.soccer.observer.Communication
All Implemented Interfaces:
java.lang.Runnable

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

The observer communication class.

Version:
$Id: Communication.java,v 1.7 2004/05/08 21:55:29 mwerla Exp $

Constructor Summary
Communication()
           
 
Method Summary
 void chooseGame(java.lang.String name)
          Chosing a game on the server to observe.
 void connect(java.lang.String ip, int port)
          Connect to a server.
 void disconnect()
          Disconnect from a server.
 java.lang.String[] getGamesList()
          Read a list of games.
 org.dom4j.Document readMessage(boolean confirm)
          Read and parse a message from a socket.
 void run()
           
 void sayHello(java.lang.String name)
          Introduce the observer to a server.
 void setObserver(Observer observer)
          Setter for observer object.
 void shutdown()
          Stops the reading loop.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Communication

public Communication()
Method Detail

connect

public void connect(java.lang.String ip,
                    int port)
             throws java.lang.Exception
Connect to a server.

Parameters:
ip -
port -
Throws:
java.lang.Exception - Thrown when connection fails.

disconnect

public void disconnect()
                throws java.lang.Exception
Disconnect from a server.

Throws:
java.lang.Exception - Thrown when disconnection fails.

sayHello

public void sayHello(java.lang.String name)
              throws java.lang.Exception
Introduce the observer to a server.

Parameters:
name - observer name
Throws:
java.lang.Exception - Thrown when message acceptation read fails.

readMessage

public org.dom4j.Document readMessage(boolean confirm)
                               throws java.lang.Exception
Read and parse a message from a socket.

Parameters:
confirm - if true the confirmation will be send
Returns:
dom4j Document
Throws:
java.lang.Exception - Thrown on read or parse error.

getGamesList

public java.lang.String[] getGamesList()
Read a list of games.

Returns:
list

chooseGame

public void chooseGame(java.lang.String name)
Chosing a game on the server to observe.

Parameters:
name - of the game

setObserver

public void setObserver(Observer observer)
Setter for observer object.

Parameters:
observer -

shutdown

public void shutdown()
Stops the reading loop.


run

public void run()
Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()


Copyright © 2001-2004 MoMaT & MWe Team. All Rights Reserved.