vooga.network.util
Class VoogaUtilsServer

java.lang.Object
  extended by java.lang.Thread
      extended by vooga.network.VoogaServer
          extended by vooga.network.util.VoogaUtilsServer
All Implemented Interfaces:
java.lang.Runnable

public class VoogaUtilsServer
extends VoogaServer

VoogaUtilsServer manages game data for myUserConnections and myLoggedOnUsers by calling NetworkDataManager methods.

Author:
tanner schmidt

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class vooga.network.VoogaServer
SERVER
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
VoogaUtilsServer()
           
 
Method Summary
 boolean containsData(java.lang.String module, java.lang.String table, java.util.List<java.lang.String> key)
          containsData checks to see if NetworkDataManager contains particular data.
 boolean containsTable(java.lang.String module, java.lang.String tableName)
          containsTable checks to see if Map of NetworkDataManagers contains particular data table.
 void createTable(java.lang.String module, java.lang.String tableName)
          createTable creates new table with tableName to new DataTable.
 void eraseData(java.lang.String module, java.lang.String table, java.util.List<java.lang.String> key)
          eraseData erases particular data in the given table stored with the given key.
 java.lang.Object getAllData(java.lang.String module, java.lang.String table)
          getData gets Map of all data in the given table.
 java.lang.Object getData(java.lang.String module, java.lang.String table, java.util.List<java.lang.String> key)
          getData gets particular data in the given table stored with the given key.
 long getNextAvailableID()
          getNextAvailableID gets the next available unique ID.
protected  void initialize()
          Allows subclasses to perform an additional initialization after the server has been constructed and started listening.
protected  void intializeConnection(java.lang.String clientName, java.net.Socket clientSocket)
          intializeConnection initializes connection.
 boolean isUserLoggedOn(java.lang.String userName)
          isUserLoggedOn checks to see if a user is logged on.
static void main(java.lang.String[] args)
           
 void setUsersLoggedOff(java.net.Socket disconnectedSocket)
          setUsersLoggedOff sets users that have disconnected sockets as logged off.
 void storeData(java.lang.String module, java.lang.String table, java.util.List<java.lang.String> key, java.lang.Object data)
          storeData stores synchronized data.
 DataObject synchronize(java.lang.String module, java.lang.String table, java.util.List<java.lang.String> key, DataObject local)
          synchronize synchronizes local data object with other data objects.
 
Methods inherited from class vooga.network.VoogaServer
getAllConnectedUsers, getInStream, getMySocket, getOutStream, listeningToSocket, removeConnection, run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VoogaUtilsServer

public VoogaUtilsServer()
                 throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getNextAvailableID

public long getNextAvailableID()
getNextAvailableID gets the next available unique ID. This value is reserved so this value will never be returned again.

Returns:
long nextUIDPointer

storeData

public void storeData(java.lang.String module,
                      java.lang.String table,
                      java.util.List<java.lang.String> key,
                      java.lang.Object data)
storeData stores synchronized data.

Parameters:
module - particular NetworkDataManager module
table - The table in which the data to be accessed is stored.
key - The data's key.
data -

eraseData

public void eraseData(java.lang.String module,
                      java.lang.String table,
                      java.util.List<java.lang.String> key)
eraseData erases particular data in the given table stored with the given key.

Parameters:
module - particular NetworkDataManager module
table - The table in which the data to be accessed is stored.
key - The data's key.

getData

public java.lang.Object getData(java.lang.String module,
                                java.lang.String table,
                                java.util.List<java.lang.String> key)
getData gets particular data in the given table stored with the given key.

Parameters:
module - particular NetworkDataManager module
table - The table in which the data to be accessed is stored.
key - The data's key.
Returns:
Object

getAllData

public java.lang.Object getAllData(java.lang.String module,
                                   java.lang.String table)
getData gets Map of all data in the given table.

Parameters:
module - particular NetworkDataManager module
table - The table in which the data to be accessed is stored.
Returns:
Map of Objects

containsData

public boolean containsData(java.lang.String module,
                            java.lang.String table,
                            java.util.List<java.lang.String> key)
containsData checks to see if NetworkDataManager contains particular data.

Parameters:
module - particular NetworkDataManager module
table - The table in which the data to be accessed is stored.
key - The data's key.
Returns:
true if NetworkDataManager contains particular data.

createTable

public void createTable(java.lang.String module,
                        java.lang.String tableName)
                 throws VoogaNetworkException
createTable creates new table with tableName to new DataTable.

Parameters:
module - particular NetworkDataManager module
tableName - name of table to be created
Throws:
VoogaNetworkException

containsTable

public boolean containsTable(java.lang.String module,
                             java.lang.String tableName)
containsTable checks to see if Map of NetworkDataManagers contains particular data table.

Parameters:
module - particular NetworkDataManager module
tableName - name of table to be queried
Returns:
true if Map contains data table

synchronize

public DataObject synchronize(java.lang.String module,
                              java.lang.String table,
                              java.util.List<java.lang.String> key,
                              DataObject local)
synchronize synchronizes local data object with other data objects.

Parameters:
module - particular NetworkDataManager module
table - The table in which the data to be accessed is stored.
key - The data's key.
local - local object to be synchronized with the other objects
Returns:
DataObject

initialize

protected void initialize()
Description copied from class: VoogaServer
Allows subclasses to perform an additional initialization after the server has been constructed and started listening.

Specified by:
initialize in class VoogaServer

intializeConnection

protected void intializeConnection(java.lang.String clientName,
                                   java.net.Socket clientSocket)
intializeConnection initializes connection.

Specified by:
intializeConnection in class VoogaServer

isUserLoggedOn

public boolean isUserLoggedOn(java.lang.String userName)
isUserLoggedOn checks to see if a user is logged on.

Parameters:
userName - user name to be queried
Returns:
true if user name is logged on

setUsersLoggedOff

public void setUsersLoggedOff(java.net.Socket disconnectedSocket)
setUsersLoggedOff sets users that have disconnected sockets as logged off.

Parameters:
disconnectedSocket -

main

public static void main(java.lang.String[] args)