org.starhope.vergil.net.smartFaux
Class SmartFauxClient

java.lang.Object
  extended by org.starhope.vergil.net.smartFaux.SmartFauxClient
All Implemented Interfaces:
GameImplementor, VergilEventHandler

public class SmartFauxClient
extends Object
implements GameImplementor

A nearly drop-in replacement for the basics of porting a SmartFox Server Pro client application to use Appius Claudius Caecus.

Author:
brpocock@star-hope.org

Field Summary
private  String connectedHost
          server to which we're connected
private  int connectedPort
          server port to which we're connected
private  String connectedZone
          server zone to which we're connected
private  boolean debug
          WRITEME: Document this brpocock@star-hope.org
private  String defaultXt
          WRITEME: Document this brpocock@star-hope.org
private  String gameCopyright
          WRITEME: Document this brpocock@star-hope.org
private  String gameLicenseBrief
          WRITEME: Document this brpocock@star-hope.org
private  String gameLicenseLong
          WRITEME: Document this brpocock@star-hope.org
private  com.google.gwt.http.client.URL gameLicenseTextLink
          WRITEME: Document this brpocock@star-hope.org
private  String gameShortID
          WRITEME: Document this brpocock@star-hope.org
private  String gameSubtitle
          WRITEME: Document this brpocock@star-hope.org
private  String gameTitle
          WRITEME: Document this brpocock@star-hope.org
 boolean smartConnect
          An ignored public boolean for compatibility purposes.
private  Socket socket
          Server connection
private  String theApple
          random key from server
 
Constructor Summary
SmartFauxClient(boolean b)
          Constructor
 
Method Summary
 void acceptEvent(String identifier, Object... details)
          WRITEME: Document this method brpocock@star-hope.org
 void addEventListener(String eventString, SmartFauxEventListener eventHandler)
          WRITEME: Document this method brpocock@star-hope.org
private  String chapPassword(String userPassword)
          WRITEME: Document this method brpocock@star-hope.org
 void connect(String server)
          Connect to a server, trying the default Smart Fox Server port (9339) and the default Appius port (2770).
 void connect(String server, int port)
          Connect to a server on a specific port.
private  com.google.gwt.json.client.JSONObject convert(org.json.JSONObject jsonObject)
          WRITEME: Document this method brpocock@star-hope.org
 void disconnect()
          Disconnect from the server, if connected.
 String getConnectedHost()
           
 int getConnectedPort()
           
 String getConnectedZone()
           
 String getGameCopyright()
           Examples:
 String getGameLicenseBrief()
           Examples:
 String getGameLicenseLong()
           Examples:
 com.google.gwt.http.client.URL getGameLicenseTextLink()
           Get a link to the full text of the license agreement.
 String getGameShortIdentifier()
          WRITEME: Document this method brpocock@star-hope.org
 String getGameSubtitle()
           
 String getGameTitle()
           
 String getRandomKey()
          May return null if the apple hasn't yet been retrieved
 void getRoomList()
          fetch and store the room list.
 boolean isDebug()
           
 void joinRoom(int i)
          WRITEME: Document this method brpocock@star-hope.org
 void joinRoom(String roomMoniker, String roomPassword, boolean b)
          WRITEME: Document this method brpocock@star-hope.org
 void login(String zoneName, String userName, String password)
          WRITEME: Document this method brpocock@star-hope.org
 void logout()
          WRITEME: Document this method brpocock@star-hope.org
 void sendJson(String string)
          WRITEME: Document this method brpocock@star-hope.org
 void sendPublicMessage(String string)
          WRITEME: Document this method brpocock@star-hope.org
 void sendXtMessage(String xtName, String xtCommand, org.json.JSONObject jsonObject)
          WRITEME: Document this method brpocock@star-hope.org
 void setDebug(boolean b)
          WRITEME: Document this method brpocock@star-hope.org
 void setDefaultXt(String prefix)
          Under SmartFox Server™, extensions are bundled into various prefices.
 void setUserVariables(Map<String,SFSVariable> vars)
          WRITEME: Document this method brpocock@star-hope.org
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

smartConnect

public boolean smartConnect
An ignored public boolean for compatibility purposes.


socket

private Socket socket
Server connection


connectedHost

private String connectedHost
server to which we're connected


connectedPort

private int connectedPort
server port to which we're connected


connectedZone

private final String connectedZone
server zone to which we're connected

See Also:
Constant Field Values

theApple

private final String theApple
random key from server


debug

private boolean debug
WRITEME: Document this brpocock@star-hope.org


gameCopyright

private String gameCopyright
WRITEME: Document this brpocock@star-hope.org


gameLicenseBrief

private String gameLicenseBrief
WRITEME: Document this brpocock@star-hope.org


gameLicenseLong

private String gameLicenseLong
WRITEME: Document this brpocock@star-hope.org


gameLicenseTextLink

private com.google.gwt.http.client.URL gameLicenseTextLink
WRITEME: Document this brpocock@star-hope.org


gameShortID

private String gameShortID
WRITEME: Document this brpocock@star-hope.org


gameSubtitle

private String gameSubtitle
WRITEME: Document this brpocock@star-hope.org


gameTitle

private String gameTitle
WRITEME: Document this brpocock@star-hope.org


defaultXt

private String defaultXt
WRITEME: Document this brpocock@star-hope.org

Constructor Detail

SmartFauxClient

public SmartFauxClient(boolean b)
Constructor

Parameters:
b - Whether to enable debugging mode
Method Detail

acceptEvent

public void acceptEvent(String identifier,
                        Object... details)
                 throws EventNotHandledException
Description copied from interface: VergilEventHandler
WRITEME: Document this method brpocock@star-hope.org

Specified by:
acceptEvent in interface VergilEventHandler
Parameters:
identifier - WRITEME
details - WRITEME
Throws:
EventNotHandledException - WRITEME
See Also:
VergilEventHandler.acceptEvent(java.lang.String, java.lang.Object[])

addEventListener

public void addEventListener(String eventString,
                             SmartFauxEventListener eventHandler)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
eventString - WRITEME
eventHandler - WRITEME

chapPassword

private String chapPassword(String userPassword)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
userPassword - WRITEME
Returns:
WRITEME

connect

public void connect(String server)
             throws UnknownHostException
Connect to a server, trying the default Smart Fox Server port (9339) and the default Appius port (2770).

Parameters:
server - The server to which to connect.
Throws:
UnknownHostException - if the server name can't be resolved

connect

public void connect(String server,
                    int port)
             throws UnknownHostException
Connect to a server on a specific port.

Parameters:
server - The server to which to connect
port - The port number on which to connect. The default for SmartFox Server is 9339; the default for Appius is 2770.
Throws:
UnknownHostException - if the given server name can't be resolved

convert

private com.google.gwt.json.client.JSONObject convert(org.json.JSONObject jsonObject)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
jsonObject - WRITEME
Returns:
WRITEME

disconnect

public void disconnect()
Disconnect from the server, if connected.


getConnectedHost

public String getConnectedHost()
Returns:
the connectedHost

getConnectedPort

public int getConnectedPort()
Returns:
the connectedPort

getConnectedZone

public String getConnectedZone()
Returns:
the connectedZone

getGameCopyright

public String getGameCopyright()
Description copied from interface: GameImplementor

Examples:

Do not include the game's title, version/release information, or license terms (e.g. “All Rights Reserved”) in this string.

Specified by:
getGameCopyright in interface GameImplementor
Returns:
A string indicating the game's copyright.
See Also:
GameImplementor.getGameCopyright()

getGameLicenseBrief

public String getGameLicenseBrief()
Description copied from interface: GameImplementor

Examples:

Specified by:
getGameLicenseBrief in interface GameImplementor
Returns:
the game's brief licensing terms
See Also:
GameImplementor.getGameLicenseBrief()

getGameLicenseLong

public String getGameLicenseLong()
Description copied from interface: GameImplementor

Examples:

Specified by:
getGameLicenseLong in interface GameImplementor
Returns:
the game's longer licensing terms
See Also:
GameImplementor.getGameLicenseLong()

getGameLicenseTextLink

public com.google.gwt.http.client.URL getGameLicenseTextLink()
Description copied from interface: GameImplementor

Get a link to the full text of the license agreement.

Some useful ones (for my own use):

Specified by:
getGameLicenseTextLink in interface GameImplementor
Returns:
a URL of the full license terms
See Also:
GameImplementor.getGameLicenseTextLink()

getGameShortIdentifier

public String getGameShortIdentifier()
Description copied from interface: GameImplementor
WRITEME: Document this method brpocock@star-hope.org

Specified by:
getGameShortIdentifier in interface GameImplementor
Returns:
WRITEME
See Also:
GameImplementor.getGameShortIdentifier()

getGameSubtitle

public String getGameSubtitle()
Specified by:
getGameSubtitle in interface GameImplementor
Returns:
the subtitle or other minor text accompanying the game's title
See Also:
GameImplementor.getGameSubtitle()

getGameTitle

public String getGameTitle()
Specified by:
getGameTitle in interface GameImplementor
Returns:
the game's official title
See Also:
GameImplementor.getGameTitle()

getRandomKey

public String getRandomKey()
May return null if the apple hasn't yet been retrieved

Returns:
random key for cryptographic exchange (CHAP)

getRoomList

public void getRoomList()
fetch and store the room list.


isDebug

public boolean isDebug()
Specified by:
isDebug in interface GameImplementor
Returns:
true, if the game is running in a debugging mode or environment
See Also:
GameImplementor.isDebug()

joinRoom

public void joinRoom(int i)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
i - WRITEME

joinRoom

public void joinRoom(String roomMoniker,
                     String roomPassword,
                     boolean b)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
roomMoniker - WRITEME
roomPassword - ignored
b - ignored

login

public void login(String zoneName,
                  String userName,
                  String password)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
zoneName - WRITEME
userName - WRITEME
password - WRITEME

logout

public void logout()
WRITEME: Document this method brpocock@star-hope.org


sendJson

public void sendJson(String string)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
string - something that might have once been JSON

sendPublicMessage

public void sendPublicMessage(String string)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
string - WRITEME

sendXtMessage

public void sendXtMessage(String xtName,
                          String xtCommand,
                          org.json.JSONObject jsonObject)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
xtName - WRITEME
xtCommand - WRITEME
jsonObject - WRITEME

setDebug

public void setDebug(boolean b)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
b - WRITEME

setDefaultXt

public void setDefaultXt(String prefix)
Under SmartFox Server™, extensions are bundled into various prefices. Appius doesn't do that. So, set the default Xt prefix to the one that you want to map to the basic namespace. Most users will call this once at startup and then forget about it.

Parameters:
prefix - The Xt code that should not be made into a prefix on server calls.

setUserVariables

public void setUserVariables(Map<String,SFSVariable> vars)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
vars - WRITEME