org.mega.gasp.client.doja
Class GASPClient

java.lang.Object
  extended byorg.mega.gasp.client.doja.GASPClient

public abstract class GASPClient
extends java.lang.Object

A game client logic running with GASP must implement this class, GASPClient.

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

Field Summary
protected static com.nttdocomo.io.HttpConnection connection
           
protected  CustomTypes customTypes
           
private static java.io.DataInputStream dis
           
private static java.io.DataOutputStream dos
           
private static java.lang.String GASPServletUrl
          Explanation: A Doja specific GASPClient has been created to reduce the number of methods (firstLogin, login, createAI, createPrivateAI, joinAI, joinAIRnd) because the code size is critical in IApplis.
 
Constructor Summary
GASPClient()
           
 
Method Summary
private static void closeAllConnection()
          Close all connection streams and the connection.
protected  void endAI(int aSID)
          (Try to) End the game if the user is the owner of the application instance.
private  void eventsOf(java.io.DataInputStream dis)
          Treats the events of the servlet response data input stream.
protected  void getEvents(int aSID)
          Provide to get the events in user actorSession on the Platform.
abstract  void initCustomTypes()
           
abstract  void onDataEvent(int actorSessionID, java.util.Hashtable datas)
          Method called when a DataEvent is received from the platform.
abstract  void onEndEvent(int actorSessionID)
          Method called when a EndEvent is received from the platform.
abstract  void onJoinEvent(int actorSessionID, java.lang.String username)
          Method called when a JoinEvent is received from the platform.
abstract  void onQuitEvent(int actorSessionID)
          Method called when a QuitEvent is received from the platform.
abstract  void onStartEvent(int actorSessionID)
          Method called when a StartEvent is received from the platform.
private static com.nttdocomo.io.HttpConnection openPostConnection(java.lang.String url)
           
protected  void quit(int sID)
          Quit the platform.
protected  void quitAI(int aSID)
          Quit the ApplicationInstance joined.
protected  void sendData(int aSID, java.util.Hashtable h)
          Provide to send in game datas to the Platform.
private  java.io.DataInputStream servletRequest(java.lang.String servletName, java.lang.String formData)
          Send a request to the specified servlet with the http post parameters.
private  java.io.DataInputStream servletSendDataRequest(java.lang.String servletName, int aSID, java.util.Hashtable h)
          Send the data in the hashtable to the specified servlet.
protected  void startAI(int aSID)
          (Try to) Start the game if the user is the owner of the application instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GASPServletUrl

private static java.lang.String GASPServletUrl
Explanation: A Doja specific GASPClient has been created to reduce the number of methods (firstLogin, login, createAI, createPrivateAI, joinAI, joinAIRnd) because the code size is critical in IApplis. These methods must be delegated to a web service (another servlet independant from GASP) Thus, HTTP implementation is different between MIDP and Doja.


customTypes

protected CustomTypes customTypes

connection

protected static com.nttdocomo.io.HttpConnection connection

dos

private static java.io.DataOutputStream dos

dis

private static java.io.DataInputStream dis
Constructor Detail

GASPClient

public GASPClient()
Method Detail

initCustomTypes

public abstract void initCustomTypes()

getEvents

protected void getEvents(int aSID)
Provide to get the events in user actorSession on the Platform.

Parameters:
aSID - the ActorSession ID
Returns:
a vector of events send by the platform

startAI

protected void startAI(int aSID)
(Try to) Start the game if the user is the owner of the application instance. For manual mode only.

Parameters:
aSID -

endAI

protected void endAI(int aSID)
(Try to) End the game if the user is the owner of the application instance. For manual mode only.

Parameters:
aSID -

quitAI

protected void quitAI(int aSID)
Quit the ApplicationInstance joined.

Parameters:
aSID - the ActorSession ID

sendData

protected void sendData(int aSID,
                        java.util.Hashtable h)
Provide to send in game datas to the Platform.

Parameters:
aSID - the ActorSession ID
h - the hashtable of datas
Returns:
a vector of events send by the platform

eventsOf

private void eventsOf(java.io.DataInputStream dis)
               throws java.io.IOException
Treats the events of the servlet response data input stream.

Parameters:
dis - the data input strem
Returns:
Throws:
java.io.IOException

quit

protected void quit(int sID)
Quit the platform.

Parameters:
sID - the Session ID of the user

servletRequest

private java.io.DataInputStream servletRequest(java.lang.String servletName,
                                               java.lang.String formData)
                                        throws java.lang.Exception
Send a request to the specified servlet with the http post parameters. Return the servlet response DataInputStream.

Parameters:
servletName - the name of the servlet
formData - the HTTP post parameters
Returns:
the DataInputStream
Throws:
java.io.IOException
java.lang.Exception

servletSendDataRequest

private java.io.DataInputStream servletSendDataRequest(java.lang.String servletName,
                                                       int aSID,
                                                       java.util.Hashtable h)
                                                throws java.lang.Exception
Send the data in the hashtable to the specified servlet.

Parameters:
servletName - the name of the servlet
Returns:
the DataInputStream of the servlet response
Throws:
java.io.IOException
java.lang.Exception

openPostConnection

private static com.nttdocomo.io.HttpConnection openPostConnection(java.lang.String url)
                                                           throws java.lang.Exception
Throws:
java.lang.Exception

closeAllConnection

private static void closeAllConnection()
Close all connection streams and the connection.


onJoinEvent

public abstract void onJoinEvent(int actorSessionID,
                                 java.lang.String username)
Method called when a JoinEvent is received from the platform.

Parameters:
actorSessionID -
username -

onStartEvent

public abstract void onStartEvent(int actorSessionID)
Method called when a StartEvent is received from the platform.

Parameters:
actorSessionID -

onEndEvent

public abstract void onEndEvent(int actorSessionID)
Method called when a EndEvent is received from the platform.

Parameters:
actorSessionID -

onQuitEvent

public abstract void onQuitEvent(int actorSessionID)
Method called when a QuitEvent is received from the platform.

Parameters:
actorSessionID -

onDataEvent

public abstract void onDataEvent(int actorSessionID,
                                 java.util.Hashtable datas)
Method called when a DataEvent is received from the platform.

Parameters:
actorSessionID -
datas - the hashtable of datas