de.tubs.macs.control.net
Class SystemNet

java.lang.Object
  |
  +--de.tubs.macs.control.net.SystemNet

public class SystemNet
extends java.lang.Object
implements NetReceiver

This class provides a convenient way for the control to handle its communication via the network. Basically, SystemNet implements a Protocol used for communication between different MACS-Controls. Coding, decoding and addressing are done by SystemNet, as well as the scheduling of the calling threads. SystemNet needs some of MacsControl public variables/services:

These MUST be initialized before SystemNet is created!


Field Summary
static int CODE_EXPIRED
          code constant for expire (timeout)
static int CODE_IGNORE
          code constant for command ignored
static int CODE_INVITE_DELAYED
          code constant for delayed invite
static int CODE_INVITE_DENIED
          code constant for denied invite
static int CODE_JOIN_DELAYED
          code constant for delayed join
static int CODE_JOIN_DENIED
          code constant for denied joins
static int CODE_LEAVE_DENIED
          code constant for denied leave
static int CODE_OK
          code constant for success
static int CODE_RESOURCE_USED
          code constant for command ignored
static int CODE_SESSION_EXISTS
          code constant for session exists
static int CODE_TERMINATE_DENIED
          code constant for denied terminate
static int CODE_UNKNOWN_ERROR
          code constant for some unknown error
static java.lang.String[] codes
          provide string represenatations of codes
static java.lang.String DEBUG_KEY
          key for debug info
 int net_periode_basic
           
static java.lang.String NET_PERIODE_BASIC
          keys for net timings
 int net_periode_create
           
static java.lang.String NET_PERIODE_CREATE
           
static java.lang.String NET_PERIODE_EXPIRE_SESSION
           
static java.lang.String NET_PERIODE_EXPIRE_USER
           
 int net_periode_others
           
static java.lang.String NET_PERIODE_OTHERS
           
static int STATE_ENTER
          state constant for a new system/session/user
static int STATE_LEAVE
          state constant for a leaving system/session/user
static int STATE_PERIOD
          state constant for alive (heart-beat) of a system/session/user
static int STATE_REFRESH
          state constant for update-request of a REMOTE-system/session/user This indication MUST contain the remote-user to be updated
static int STATE_UPDATE
          state constant for a update about a system/session/user
static java.lang.String[] states
          provide string represenatations of states
static int VERSION_MAJOR
          version constant major
static int VERSION_MINOR
          version constant minor
static java.lang.String VERSION_STRING
          version constant as a string (V"MAJOR"."MINOR")
 
Constructor Summary
SystemNet(NetAddress address)
          Initialize SystemNet.
 
Method Summary
 void addSystemNetListener(SystemNetListener newlistener)
          This method is used to register a new listener.
 SessionNet createSession(Session session)
          Create the network stub for a session (SessionNet).
 void exit()
          Send leave message and close connections.
 java.lang.String getType()
          return the type of Net used.
 Status invite(ObjectID session_id, ObjectID user, long req_num, java.io.Serializable user_data)
          Invite a user.
 SessionNet joinSession(Session session, long request, java.io.Serializable user_data)
          Join a existing session.
 void receiveException(NetException exception)
          part of NetReceiver interface
 void receiveObject(java.lang.Object object, Net net)
          part of NetReceiver interface
 void removeSystemNetListener(SystemNetListener oldlistener)
          This method is used to remove a registered listener.
 MACSResponse sendRequestAndWaitForResponse(MACSRequest req, long timeout)
           
 void sendSessionCreateResponse(MACSSessionCreateRequest req, int result)
          Similar to sendSessionIndication(Session,int), but with additional parameter to customize user.
 void sendSessionIndication(SessionData sdata, int type, ObjectID userID)
          Similar to sendSessionIndication(Session,int), but with additional parameter to customize user.
 void sendSessionInviteResponse(MACSSessionInviteRequest req, int result, java.io.Serializable user_data)
           
 void sendSystemIndication(User user, int type)
          send SystemIndication
 void sendSystemLeave(User user)
          Send SystemIndication to announce this system left.
 void sendTestCreateUsers(int num)
           
 void sendTestStart(int interval)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_MAJOR

public static final int VERSION_MAJOR
version constant major

VERSION_MINOR

public static final int VERSION_MINOR
version constant minor

VERSION_STRING

public static final java.lang.String VERSION_STRING
version constant as a string (V"MAJOR"."MINOR")

STATE_ENTER

public static final int STATE_ENTER
state constant for a new system/session/user

STATE_LEAVE

public static final int STATE_LEAVE
state constant for a leaving system/session/user

STATE_UPDATE

public static final int STATE_UPDATE
state constant for a update about a system/session/user

STATE_PERIOD

public static final int STATE_PERIOD
state constant for alive (heart-beat) of a system/session/user

STATE_REFRESH

public static final int STATE_REFRESH
state constant for update-request of a REMOTE-system/session/user This indication MUST contain the remote-user to be updated

states

public static final java.lang.String[] states
provide string represenatations of states

CODE_OK

public static final int CODE_OK
code constant for success

CODE_EXPIRED

public static final int CODE_EXPIRED
code constant for expire (timeout)

CODE_UNKNOWN_ERROR

public static final int CODE_UNKNOWN_ERROR
code constant for some unknown error

CODE_SESSION_EXISTS

public static final int CODE_SESSION_EXISTS
code constant for session exists

CODE_JOIN_DENIED

public static final int CODE_JOIN_DENIED
code constant for denied joins

CODE_LEAVE_DENIED

public static final int CODE_LEAVE_DENIED
code constant for denied leave

CODE_TERMINATE_DENIED

public static final int CODE_TERMINATE_DENIED
code constant for denied terminate

CODE_INVITE_DENIED

public static final int CODE_INVITE_DENIED
code constant for denied invite

CODE_JOIN_DELAYED

public static final int CODE_JOIN_DELAYED
code constant for delayed join

CODE_INVITE_DELAYED

public static final int CODE_INVITE_DELAYED
code constant for delayed invite

CODE_IGNORE

public static final int CODE_IGNORE
code constant for command ignored

CODE_RESOURCE_USED

public static final int CODE_RESOURCE_USED
code constant for command ignored

codes

public static final java.lang.String[] codes
provide string represenatations of codes

DEBUG_KEY

public static final java.lang.String DEBUG_KEY
key for debug info

NET_PERIODE_BASIC

public static final java.lang.String NET_PERIODE_BASIC
keys for net timings

NET_PERIODE_CREATE

public static final java.lang.String NET_PERIODE_CREATE

NET_PERIODE_EXPIRE_USER

public static final java.lang.String NET_PERIODE_EXPIRE_USER

NET_PERIODE_EXPIRE_SESSION

public static final java.lang.String NET_PERIODE_EXPIRE_SESSION

NET_PERIODE_OTHERS

public static final java.lang.String NET_PERIODE_OTHERS

net_periode_basic

public int net_periode_basic

net_periode_create

public int net_periode_create

net_periode_others

public int net_periode_others
Constructor Detail

SystemNet

public SystemNet(NetAddress address)
          throws NetException
Initialize SystemNet. Only fully initialized for the local user. All others have to call sendSystemIndication(User,int) afterwards to announce themselves on the net.
Parameters:
group - string with address of network group
options - string with network options
Method Detail

sendSystemIndication

public void sendSystemIndication(User user,
                                 int type)
send SystemIndication

sendRequestAndWaitForResponse

public MACSResponse sendRequestAndWaitForResponse(MACSRequest req,
                                                  long timeout)

receiveObject

public void receiveObject(java.lang.Object object,
                          Net net)
part of NetReceiver interface
Specified by:
receiveObject in interface NetReceiver
Tags copied from interface: NetReceiver
Parameters:
object - received
net - which did receive this object (allows one NetReceiver to be used for more than one Net)

receiveException

public void receiveException(NetException exception)
part of NetReceiver interface
Specified by:
receiveException in interface NetReceiver
Tags copied from interface: NetReceiver
Parameters:
exception - received from Net

addSystemNetListener

public void addSystemNetListener(SystemNetListener newlistener)
This method is used to register a new listener.

removeSystemNetListener

public void removeSystemNetListener(SystemNetListener oldlistener)
This method is used to remove a registered listener.

invite

public Status invite(ObjectID session_id,
                     ObjectID user,
                     long req_num,
                     java.io.Serializable user_data)
Invite a user. As the user is not in the session this has to be send on the global channel and therefore by SystemNet. This function is only called by the invite of SessionNet! Note: Always uses local user as sender, as its not needed by the ITU Gateway

sendSystemLeave

public void sendSystemLeave(User user)
Send SystemIndication to announce this system left. Parameter to customize sending user.

sendSessionIndication

public void sendSessionIndication(SessionData sdata,
                                  int type,
                                  ObjectID userID)
Similar to sendSessionIndication(Session,int), but with additional parameter to customize user.
Parameters:
session - the data describing the session
type - the type of indication send (e.g. SATE_ENTER)
user - sending user

sendSessionCreateResponse

public void sendSessionCreateResponse(MACSSessionCreateRequest req,
                                      int result)
                               throws NetException
Similar to sendSessionIndication(Session,int), but with additional parameter to customize user.
Parameters:
session - the data describing the session
type - the type of indication send (e.g. STATE_ENTER)
user - sending user

sendSessionInviteResponse

public void sendSessionInviteResponse(MACSSessionInviteRequest req,
                                      int result,
                                      java.io.Serializable user_data)
                               throws NetException

exit

public void exit()
Send leave message and close connections.

createSession

public SessionNet createSession(Session session)
Create the network stub for a session (SessionNet). SessionNet offers a convinient way for the session controlers to communicate with each other (similiar like SystemNet to the MacsControl). Note: Uses MacsControl.localuser as sender identifier!!!
Parameters:
session - the data describing the session

joinSession

public SessionNet joinSession(Session session,
                              long request,
                              java.io.Serializable user_data)
Join a existing session.
Parameters:
session - the data describing the session
user_data - application/controller dependend data (optional)
request - number of the invite request (if applicable, else 0)

getType

public java.lang.String getType()
return the type of Net used.

sendTestCreateUsers

public void sendTestCreateUsers(int num)

sendTestStart

public void sendTestStart(int interval)