Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

marauroa.net
Class NetworkServerManager  view NetworkServerManager download NetworkServerManager.java

java.lang.Object
  extended bymarauroa.net.NetworkServerManager

public class NetworkServerManager
extends java.lang.Object

The NetworkServerManager is the active entity of the marauroa.net package, it is in charge of sending and recieving the packages from the network.


Nested Class Summary
(package private)  class NetworkServerManager.NetworkServerManagerRead
          The active thread in charge of recieving messages from the network.
(package private)  class NetworkServerManager.NetworkServerManagerWrite
          A wrapper class for sending messages to clients
 
Field Summary
private  boolean isfinished
          isFinished is true when the thread has really exited.
private  boolean keepRunning
          While keepRunning is true, we keep recieving messages
private  java.util.List messages
          A List of Message objects: List
private  MessageFactory msgFactory
           
private  NetworkServerManager.NetworkServerManagerRead readManager
           
private  java.net.DatagramSocket socket
          The server socket from where we recieve the packets.
private  NetworkServerManager.NetworkServerManagerWrite writeManager
           
 
Constructor Summary
NetworkServerManager()
          Constructor that opens the socket on the marauroa_PORT and start the thread to recieve new messages from the network.
 
Method Summary
 void addMessage(Message msg)
          This method add a message to be delivered to the client the message is pointed to.
 void finish()
          This method notify the thread to finish it execution
 Message getMessage()
          This method blocks until a message is available
 Message getMessage(int timeout)
          This method returns a Message from the list or block for timeout milliseconds until a message is available or null if timeout happens.
private  void newMessageArrived()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

socket

private java.net.DatagramSocket socket
The server socket from where we recieve the packets.


keepRunning

private boolean keepRunning
While keepRunning is true, we keep recieving messages


isfinished

private boolean isfinished
isFinished is true when the thread has really exited.


messages

private java.util.List messages
A List of Message objects: List


msgFactory

private MessageFactory msgFactory

readManager

private NetworkServerManager.NetworkServerManagerRead readManager

writeManager

private NetworkServerManager.NetworkServerManagerWrite writeManager
Constructor Detail

NetworkServerManager

public NetworkServerManager()
                     throws java.net.SocketException
Constructor that opens the socket on the marauroa_PORT and start the thread to recieve new messages from the network.

Method Detail

finish

public void finish()
This method notify the thread to finish it execution


newMessageArrived

private void newMessageArrived()

getMessage

public Message getMessage(int timeout)
This method returns a Message from the list or block for timeout milliseconds until a message is available or null if timeout happens.


getMessage

public Message getMessage()
This method blocks until a message is available


addMessage

public void addMessage(Message msg)
This method add a message to be delivered to the client the message is pointed to.