GameFish

The GameFish framework will be a collection of objects in C# enabling easy establishment of client/server communication through UDP, live interpretation of Python Script through the use of IronPython, task scheduling through built in thread pool and timed task management system, an XML parser and for easy data storage, and timed task management system, and potentially a simple graphics utility. By bundling all of these objects together under the simple GameFish API, all this vital functionality can be quickly added in a standardized way to any C# application in need of them.

PythonFish
Handles all IronPython script compilation and execution.

IronPython.Hosting.PythonEngine PE
The main IronPython PythonEngine object which handles interpretation of python script.

System.Collections.Hashtable Scripts
A hashtable of loaded IronPython.Hosting.CompiledCode objects referenced by script name.

public PythonFish
Class constructor which initializes properties and imports default modules to be used by the PythonEngine.

public void AddPath(string path)
Provides an interface to the PythonEngine.AddToPath method.

public bool LoadScript(string name, string code)
Compiles a string of Python script and stores the compiled code object in Scripts.

public void RunScript(string name)
Execute a previously loaded script.

public void AddGlobal(string var, object obj)
Interface to PythonEngine.Globals allowing reference of user .Net objects in the Python script.

ServeFish
Handles UDP communication for the server end.

UDPServe.UDP_Carrier carry
Interface to a UDPClient object setup to send packets.

UDPServe.UDP_Listener listen
Interface to a UDPClient object setup to recieve packets.

System.Threading.Thread tExchange
A thread which monitors the InBox and OutBox.

System.Collections.Queue InBox
Queue of processed FishGram objects representing incoming client messages.

System.Collections.Queue OutBox
Queue of processed FishGram objects representing outgoing server messages.

public System.Collections.Hashtable School
Hashtable of UserFish objects sorted by user name.

public int tick
Interval between server updates.

public int inPort
Listening Port.

public int outPort
Sending Port.

public ServeFish(int iPort, int oPort)
Class Constructor which initializes properties.

public void Go
Starts the listener receiving packets and starts tExchange thread processing them.

public void Pause
Pause tExchange and thus pause the server. Note that the server continues to receive packets while paused, it just doesn't process them.

public void Resume
Resume tExchange after a Pause.

public void Stop
Terminate/dispose of tExchange and shutdown all UDP connections.

public int Pending
Retrieves the number of FishGrams pending in the InBox.

public FishGram PopMessage
Get the next FishGram from the InBox queue.

public void PushMessage(FishGram message)
Add a FishGram to the OutBox queue.

public string[] GetUsers
Returns an array of authenticated user names.

void Process
An internal member called by ThreadProcess every server tick. Services pending FishGrams in both queues.

void ThreadProcess
Internal method run by tExchange.