org.mega.gasp.platform
Interface ApplicationInstance

All Superinterfaces:
OnDataEvent, OnEndEvent, OnEvent, OnJoinEvent, OnQuitEvent, OnStartEvent
All Known Implementing Classes:
ApplicationInstanceImpl

public interface ApplicationInstance
extends OnJoinEvent, OnStartEvent, OnEndEvent, OnDataEvent, OnQuitEvent

ApplicationInstance represent a game session of a specific application. It contains a vector of ActorSession representing the actors want to play in. This classes manage the in game events.

Author:
PELLERIN Romain (pellerin@cnam.fr) - MEGA Project

Method Summary
 int actorSessionSize()
          Returns the current number of ActorSession objects, e.g the number of actors ready to play this game session.
 boolean addActorSession(ActorSession actorSession)
          Add the actor to the actors vector.
 boolean containsActorSession(int actorSessionID)
          Determine if the ActorSession associated with the ActorSession ID is contained by this ApplicationInstance or not.
 int createNewActorSession(int aIID, Session session)
          Create a new ActorSession in the ApplicationInstance corresponding to the user Session object informations.
 java.util.Iterator enumerateActorSession()
          Returns an iterator on the actor sessions vector.
 ActorSession getActorSession(int actorSessionID)
          Returns the ActorSession object corresponding to the ActorSession ID.
 int getApplicationInstanceID()
          Returns the ID of the ApplicationInstance.
 ApplicationInstanceInfos getApplicationInstanceInfos()
          For Lobby service, this method provide informations of the ApplicationInstance.
 CustomTypes getCustomTypes()
          Returns the encoder of the application associated with the application instance.
 int getMaxActors()
          Returns the maximum number of actors can play the game session.
 int getMinActors()
          Returns the minimum number of actors required to start the game session.
 int getOwnerAID()
          Returns the ActorId of the ApplicationInstanceID owner.
 GASPServer getServer()
          Returns the minimum number of actors required to start the game session.
 boolean isActorSessionEmpty()
          Determine if the vector of ActorSession objects is empty or not.
 boolean isDestroyable()
          Determine if the Owner Master Application must destroy the application instance or not.
 boolean isJoinable()
          Determine if the the application instance is joignable by a player or not.
 boolean isPublic()
          Determine if the ApplicationInstance is public or not.
 boolean isRunning()
          Determine if the ApplicationInstance is running or not.
 boolean isStartable()
          Determine if the the application instance is startable by the player owner or not.
 void raisePseudoModification(int actorSessionID, java.lang.String pseudoname)
          Raise a JoinEvent to all other players containing the new pseudo
 boolean removeActorSession(int actorSessionID)
          Remove the ActorSession object corresponding to the ActorSessionID.
 int retrieveApplicationID()
          Retrieve the applicationID from the master application instance.
 void sendDataToActorSession(int actorSessionID, DataEvent dataEvent)
          Send a dataEvent to a specific actorSession.
 void sendPlayersInfos(int aSID)
          Send player info to the actor session ASID.
 void setApplicationInstanceName(java.lang.String appInstanceName)
          Specify the name of the Application Instance.
 java.lang.String treatPseudo(java.lang.String name)
          If the pseudo already exist in the AI modify it, else no modifications.
 
Methods inherited from interface org.mega.gasp.listener.OnJoinEvent
onJoinEvent
 
Methods inherited from interface org.mega.gasp.listener.OnStartEvent
onStartEvent
 
Methods inherited from interface org.mega.gasp.listener.OnEndEvent
onEndEvent
 
Methods inherited from interface org.mega.gasp.listener.OnDataEvent
onDataEvent
 
Methods inherited from interface org.mega.gasp.listener.OnQuitEvent
onQuitEvent
 

Method Detail

getApplicationInstanceID

public int getApplicationInstanceID()
Returns the ID of the ApplicationInstance.

Returns:
the ApplicationInstanceID

getServer

public GASPServer getServer()
Returns the minimum number of actors required to start the game session.

Returns:
the minimum number of actors

getMinActors

public int getMinActors()
Returns the minimum number of actors required to start the game session.

Returns:
the minimum number of actors

getMaxActors

public int getMaxActors()
Returns the maximum number of actors can play the game session.

Returns:
the maximum number of actors

getOwnerAID

public int getOwnerAID()
Returns the ActorId of the ApplicationInstanceID owner.

Returns:
the Actor ID

getCustomTypes

public CustomTypes getCustomTypes()
Returns the encoder of the application associated with the application instance.

Returns:
the Actor ID

isPublic

public boolean isPublic()
Determine if the ApplicationInstance is public or not.

Returns:
boolean

isRunning

public boolean isRunning()
Determine if the ApplicationInstance is running or not.

Returns:
boolean

isDestroyable

public boolean isDestroyable()
Determine if the Owner Master Application must destroy the application instance or not.

Returns:
boolean

isJoinable

public boolean isJoinable()
Determine if the the application instance is joignable by a player or not.

Returns:
boolean

isStartable

public boolean isStartable()
Determine if the the application instance is startable by the player owner or not.

Returns:
boolean

createNewActorSession

public int createNewActorSession(int aIID,
                                 Session session)
Create a new ActorSession in the ApplicationInstance corresponding to the user Session object informations. Returns the ActorSession ID.

Parameters:
aIID - the ApplicationInstance
session - the Session object of the user
Returns:
the ActorSession ID

getActorSession

public ActorSession getActorSession(int actorSessionID)
Returns the ActorSession object corresponding to the ActorSession ID.

Parameters:
actorSessionID - the ActorSession ID
Returns:
the ActorSession object

removeActorSession

public boolean removeActorSession(int actorSessionID)
Remove the ActorSession object corresponding to the ActorSessionID.

Parameters:
actorSessionID - the ActorSesion ID
Returns:
boolean representing the operation success

isActorSessionEmpty

public boolean isActorSessionEmpty()
Determine if the vector of ActorSession objects is empty or not.

Returns:
boolean "empty or not"

actorSessionSize

public int actorSessionSize()
Returns the current number of ActorSession objects, e.g the number of actors ready to play this game session.

Returns:
the number of actors

containsActorSession

public boolean containsActorSession(int actorSessionID)
Determine if the ActorSession associated with the ActorSession ID is contained by this ApplicationInstance or not.

Parameters:
actorSessionID -
Returns:
boolean "present or not"

getApplicationInstanceInfos

public ApplicationInstanceInfos getApplicationInstanceInfos()
For Lobby service, this method provide informations of the ApplicationInstance.

Returns:
an ApplicationInstanceInfos object

enumerateActorSession

public java.util.Iterator enumerateActorSession()
Returns an iterator on the actor sessions vector.

Returns:
iterator on ActorSession vector

setApplicationInstanceName

public void setApplicationInstanceName(java.lang.String appInstanceName)
Specify the name of the Application Instance.

Parameters:
appInstanceName -

addActorSession

public boolean addActorSession(ActorSession actorSession)
Add the actor to the actors vector.

Parameters:
actorSession - the ActorSession object
Returns:
boolean of the operation success

sendDataToActorSession

public void sendDataToActorSession(int actorSessionID,
                                   DataEvent dataEvent)
Send a dataEvent to a specific actorSession.

Parameters:
actorSessionID -
dataEvent -

sendPlayersInfos

public void sendPlayersInfos(int aSID)
Send player info to the actor session ASID. In case of mobile intempestive deconnection, the reconnected mobile must know the players state of the AI.

Parameters:
aSID -

treatPseudo

public java.lang.String treatPseudo(java.lang.String name)
If the pseudo already exist in the AI modify it, else no modifications.

Parameters:
name -
Returns:
String the checked pseudo

raisePseudoModification

public void raisePseudoModification(int actorSessionID,
                                    java.lang.String pseudoname)
Raise a JoinEvent to all other players containing the new pseudo

Parameters:
actorSessionID -

retrieveApplicationID

public int retrieveApplicationID()
Retrieve the applicationID from the master application instance.