Class ClientNetwork

java.lang.Object
  extended by java.util.Observable
      extended by ClientNetwork
All Implemented Interfaces:
java.lang.Runnable

public class ClientNetwork
extends java.util.Observable
implements java.lang.Runnable

This is the network connection between server and the client It manages all outgoing and incoming messages to and from the server


Constructor Summary
ClientNetwork(java.lang.String ip, java.lang.String port)
          Creates new connection with the server
 
Method Summary
 boolean checkConnection()
          Check whether connection has been established with the server
 java.lang.String getMsg()
          Returns the message received from the server
 void run()
          Start the network connection
 void sendMsg(java.lang.String msg)
          Send message to server
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientNetwork

public ClientNetwork(java.lang.String ip,
                     java.lang.String port)
Creates new connection with the server

Parameters:
ip - The ip address of the server
port - The port number of the server
Method Detail

run

public void run()
Start the network connection

Specified by:
run in interface java.lang.Runnable

getMsg

public java.lang.String getMsg()
Returns the message received from the server


sendMsg

public void sendMsg(java.lang.String msg)
Send message to server

Parameters:
msg - Message to send to the server

checkConnection

public boolean checkConnection()
Check whether connection has been established with the server

Returns:
Is it connected to the server?