net.barkerjr.gameserver.gamespy
Class GameSpyServer

java.lang.Object
  extended by net.barkerjr.gameserver.Base
      extended by net.barkerjr.gameserver.GameServer
          extended by net.barkerjr.gameserver.UdpServer
              extended by net.barkerjr.gameserver.gamespy.GameSpyServer
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
Battlefield1942Server, UnrealEngine1Server

public abstract class GameSpyServer
extends UdpServer

Provides generic parsing and querying for GameSpy protocol servers

TODO Due to lack of reply format information in replies:

Since:
2007-11-18
Author:
BarkerJr
See Also:
Specification

Nested Class Summary
 
Nested classes/interfaces inherited from class net.barkerjr.gameserver.GameServer
GameServer.Dedicated, GameServer.Request, GameServer.RequestTimeoutException
 
Field Summary
protected  String location
          The location of the server
 
Fields inherited from class net.barkerjr.gameserver.UdpServer
servers
 
Fields inherited from class net.barkerjr.gameserver.GameServer
address, botCount, dedicated, gameDirectory, IPTOS_RELIABILITY, map, maximumPlayers, name, namespace, numberOfPlayers, passwordRequired, players, plugins, rules, updated, version
 
Fields inherited from class net.barkerjr.gameserver.Base
listeners
 
Constructor Summary
GameSpyServer(InetSocketAddress address)
          Sets up the basic server information and DOM
 
Method Summary
 String getLocation()
          The location of the server
protected  String getLocation(String code)
          Determines the region that matches the given number
protected  Player getPlayer(String key)
          Fetches or creates the given player element
 void load(GameServer.Request... requests)
          Supports: Request.BASIC Request.INFORMATION Request.PLAYERS Request.RULES Loads the given requests asynchronously
protected  void parseData(byte[] packet)
          Parses the given data
protected  GameServer.Request storePair(String key, String value)
          Processes and persists the given key/value pair in the DOM
 JSONObject toJsonObject()
          Deprecated. since 2010-03-23, use JSON.toJSON(GameServer)
 
Methods inherited from class net.barkerjr.gameserver.UdpServer
close, sendData, sendData
 
Methods inherited from class net.barkerjr.gameserver.GameServer
addPlugin, equals, fireChangeEvent, fireLoadEvent, getBotCount, getDedicated, getGameDirectory, getIP, getMap, getMaximumPlayers, getName, getNumberOfPlayers, getPlayers, getPlugins, getPort, getRules, getUpdated, getVersion, handleError, hashCode, isPasswordRequired, load, replaceChild, toString, toXmlDocument
 
Methods inherited from class net.barkerjr.gameserver.Base
addListener, removeListener
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

location

protected String location
The location of the server

Since:
2009-05-02
Constructor Detail

GameSpyServer

public GameSpyServer(InetSocketAddress address)
Sets up the basic server information and DOM

Parameters:
address - the address of the server
Since:
2007-11-18
Method Detail

parseData

protected void parseData(byte[] packet)
Description copied from class: UdpServer
Parses the given data

Specified by:
parseData in class UdpServer
Parameters:
packet - the bytes in the packet
Since:
2007-11-18

storePair

protected GameServer.Request storePair(String key,
                                       String value)
Processes and persists the given key/value pair in the DOM

Parameters:
key - the key for the rule, etc
value - the value of the given key
Returns:
the request type this data belongs to, or null if it was not persisted
Since:
2007-11-18

getPlayer

protected Player getPlayer(String key)
Fetches or creates the given player element

Parameters:
key - the player number
Returns:
the DOM element representing the player
Since:
2007-11-18

load

public void load(GameServer.Request... requests)
          throws IOException
Supports: Loads the given requests asynchronously

Overrides:
load in class GameServer
Parameters:
requests - the requests to load
Throws:
IOException - if there was an error sending or receiving the data
Since:
2007-11-18

getLocation

protected String getLocation(String code)
Determines the region that matches the given number

Parameters:
code - the region number
Returns:
the region name

toJsonObject

@Deprecated
public JSONObject toJsonObject()
                        throws JSONException
Deprecated. since 2010-03-23, use JSON.toJSON(GameServer)

Description copied from class: GameServer
Converts the server into a JSON object

Overrides:
toJsonObject in class GameServer
Returns:
the object describing this server
Throws:
JSONException - if an error occurs
Since:
2009-05-02

getLocation

public String getLocation()
The location of the server

Returns:
the location of the server
Since:
2009-05-02