net.sf.opensmus
Class ServerSideScript

java.lang.Object
  extended by net.sf.opensmus.ServerSideScript
All Implemented Interfaces:
ServerUser

public class ServerSideScript
extends java.lang.Object
implements ServerUser

Base class representing a ServerSideScript object. All server side scripts must extend this class.
The ServerSideScript class implements the ServerUser interface, so scripts can join movies and send/receive messages as if they were a connected user.
Server side scripts are instantiated when a movie is created on the server. Classes are mapped to movies according to the Scriptmap.cfg file.
Messages that are addressed to a server side script should be sent with the system.script.* prefix.


Field Summary
 int m_userlevel
          The user access level for this script.
 
Constructor Summary
ServerSideScript()
          Constructor.
 
Method Summary
 long creationTime()
          Gets this scripts's creationTime on the server.
 void deleteUser()
          Scripts should not call this method, it is reserved for internal use of OpenSMUS.
 java.util.Vector<java.lang.String> getGroupNames()
          Gets a list of the groups this script is a member of.
 java.util.Vector<ServerGroup> getGroups()
          Gets a list of the groups this script is a member of.
 int getGroupsCount()
          Gets the number of groups this script is a member of.
 void groupCreate(ServerGroup grp)
          Called by the OpenSMUS server when a group is created in the movie associated with this server side script.
 void groupDelete(ServerGroup grp)
          Called by the OpenSMUS server when a group is deleted from the movie associated with this server side script.
 void groupJoin(ServerUser usr, ServerGroup grp)
          Called by the OpenSMUS server when a user joins a group in the movie associated with this server side script.
 void groupJoined(ServerGroup grp)
          Called by the OpenSMUS server when the script joins a group.
 void groupLeave(ServerUser usr, ServerGroup grp)
          Called by the OpenSMUS server when a user leaves a group in the movie associated with this server side script.
 void groupLeft(ServerGroup grp)
          Called by the OpenSMUS server when the script leaves a group.
 void incomingMessage(ServerUser user, MUSMessage msg)
          Called by the OpenSMUS server when a message addressed to this script object arrives.
 void initScript(ServerObject srv, ServerMovie mov)
          Reserved for internal use of OpenSMUS.
 java.lang.String ipAddress()
          Returns "localhost" for server side scripts.
 java.lang.String name()
          Gets the script name.
 void postMessage(MUSMessage msg)
          Posts a message to the OpenSMUS server dispatcher.
 void scriptCreate()
          Called by the OpenSMUS server when the script object is created on the server.
 void scriptDelete()
          Called by the OpenSMUS server when the script object is destroyed on the server.
 void sendMessage(MUSMessage msg)
          Sends a message to this script directly.
 ServerMovie serverMovie()
          Retrieves a pointer to the server movie object that created this script.
 ServerObject serverObject()
          Retrieves a pointer to a ServerObject instance representing the current server.
 void setuserLevel(int level)
          Sets the user access level for this script.
 int userLevel()
          Gets the user access level for this script.
 void userLogOff(ServerUser usr)
          Called by the OpenSMUS server when a user is disconnected from the movie associated with this server side script.
 void userLogOn(ServerUser usr)
          Called by the OpenSMUS server when a user connects to the movie associated with this server side script.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_userlevel

public int m_userlevel
The user access level for this script. Default is 100.

Constructor Detail

ServerSideScript

public ServerSideScript()
Constructor. Reserved for internal use of OpenSMUS.

Method Detail

serverObject

public ServerObject serverObject()
Retrieves a pointer to a ServerObject instance representing the current server.


initScript

public void initScript(ServerObject srv,
                       ServerMovie mov)
Reserved for internal use of OpenSMUS.
Scripts should implement the scriptCreate() method to perform initialization tasks.


incomingMessage

public void incomingMessage(ServerUser user,
                            MUSMessage msg)
Called by the OpenSMUS server when a message addressed to this script object arrives.
Scripts should implement this method to receive message from other users. Messages should be addressed to system.script.*, and are passed intact for processing.

Parameters:
user - ServerUser reference, representing the user that has sent the message.
msg - Message to be processed.

scriptCreate

public void scriptCreate()
Called by the OpenSMUS server when the script object is created on the server. Scripts should implement this method to perform initialization tasks.


scriptDelete

public void scriptDelete()
Called by the OpenSMUS server when the script object is destroyed on the server. Scripts should implement this method to perform cleanup tasks.


userLogOn

public void userLogOn(ServerUser usr)
Called by the OpenSMUS server when a user connects to the movie associated with this server side script.

Parameters:
usr - ServerUser reference

userLogOff

public void userLogOff(ServerUser usr)
Called by the OpenSMUS server when a user is disconnected from the movie associated with this server side script.

Parameters:
usr - ServerUser reference

groupCreate

public void groupCreate(ServerGroup grp)
Called by the OpenSMUS server when a group is created in the movie associated with this server side script.

Parameters:
grp - ServerGroup reference

groupDelete

public void groupDelete(ServerGroup grp)
Called by the OpenSMUS server when a group is deleted from the movie associated with this server side script.

Parameters:
grp - ServerGroup reference

groupJoin

public void groupJoin(ServerUser usr,
                      ServerGroup grp)
Called by the OpenSMUS server when a user joins a group in the movie associated with this server side script.

Parameters:
usr - ServerUser reference
grp - ServerGroup reference

groupLeave

public void groupLeave(ServerUser usr,
                       ServerGroup grp)
Called by the OpenSMUS server when a user leaves a group in the movie associated with this server side script.

Parameters:
usr - ServerUser reference
grp - ServerGroup reference

sendMessage

public void sendMessage(MUSMessage msg)
Sends a message to this script directly. Message will be received by the incomingMessage() method.
This method is implemented for compatibility with the ServerUser interface.

Specified by:
sendMessage in interface ServerUser
Parameters:
msg - Message to send

postMessage

public void postMessage(MUSMessage msg)
Posts a message to the OpenSMUS server dispatcher.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
postMessage in interface ServerUser
Parameters:
msg - Message to post

name

public java.lang.String name()
Gets the script name.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
name in interface ServerUser

userLevel

public int userLevel()
Gets the user access level for this script.
By default all scripts are instantiated with full privileges (userlevel 100).
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
userLevel in interface ServerUser

setuserLevel

public void setuserLevel(int level)
Sets the user access level for this script.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
setuserLevel in interface ServerUser
Parameters:
level - new user access level

serverMovie

public ServerMovie serverMovie()
Retrieves a pointer to the server movie object that created this script.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
serverMovie in interface ServerUser
Returns:
ServerMovie pointer

creationTime

public long creationTime()
Gets this scripts's creationTime on the server.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
creationTime in interface ServerUser

ipAddress

public java.lang.String ipAddress()
Returns "localhost" for server side scripts.
This method is implemented for compatibility with the ServerUser interface.

Specified by:
ipAddress in interface ServerUser

getGroupNames

public java.util.Vector<java.lang.String> getGroupNames()
Gets a list of the groups this script is a member of.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
getGroupNames in interface ServerUser
Returns:
Java Vector with the group names as Strings.

getGroups

public java.util.Vector<ServerGroup> getGroups()
Gets a list of the groups this script is a member of.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
getGroups in interface ServerUser
Returns:
Java Vector with the groups.

getGroupsCount

public int getGroupsCount()
Gets the number of groups this script is a member of.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
getGroupsCount in interface ServerUser
Returns:
the number of groups

deleteUser

public void deleteUser()
Scripts should not call this method, it is reserved for internal use of OpenSMUS.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
deleteUser in interface ServerUser

groupJoined

public void groupJoined(ServerGroup grp)
Called by the OpenSMUS server when the script joins a group.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
groupJoined in interface ServerUser
Parameters:
grp - ServerGroup reference

groupLeft

public void groupLeft(ServerGroup grp)
Called by the OpenSMUS server when the script leaves a group.
This method is part of the ServerUser interface implemented by ServerSideScript objects.

Specified by:
groupLeft in interface ServerUser
Parameters:
grp - ServerGroup reference