core
Class ClientNetworkThread

java.lang.Object
  extended by core.ClientNetworkThread
All Implemented Interfaces:
Runnable

public class ClientNetworkThread
extends Object
implements Runnable

This class runs as a separate Thread managing network data.

Author:
Terje

Field Summary
protected  BufferedReader is
           
protected  LectureGame lega
           
protected  Thread networkThread
           
protected  PrintWriter os
           
protected  int protocolState
           
 String received
           
protected  Socket socket
           
protected  boolean stringBuffered
           
 
Constructor Summary
ClientNetworkThread(LectureGame lega)
           
 
Method Summary
 void close()
          Sends a request for close message to the server which initiatez closing of the connection.
 String receive()
          Strips off protocol specific headers from the inputStream and returns the remaining String.
 void run()
          initiates connection to the server and constantly listens for incomming data and routs them to appropriate methods for reception and parsing.
 void send(String str)
          Sends the given String to the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lega

protected LectureGame lega

os

protected PrintWriter os

is

protected BufferedReader is

socket

protected Socket socket

protocolState

protected int protocolState

stringBuffered

protected boolean stringBuffered

received

public String received

networkThread

protected Thread networkThread
Constructor Detail

ClientNetworkThread

public ClientNetworkThread(LectureGame lega)
Method Detail

run

public void run()
initiates connection to the server and constantly listens for incomming data and routs them to appropriate methods for reception and parsing.

Specified by:
run in interface Runnable

receive

public String receive()
Strips off protocol specific headers from the inputStream and returns the remaining String. Incoming data not following protocol is results in the return of the value null.

Returns:

close

public void close()
Sends a request for close message to the server which initiatez closing of the connection.


send

public void send(String str)
Sends the given String to the server.

Parameters:
str -