Winbolonet

From WinBolo

(Difference between revisions)
Jump to: navigation, search
Current revision (16:14, 29 November 2008) (view source)
(winbolonet.c)
 
(One intermediate revision not shown.)
Line 5: Line 5:
winbolonet.c is the entry point for code to access winbolo.net. Servers use the module the most. Clients only use it to request a client key.
winbolonet.c is the entry point for code to access winbolo.net. Servers use the module the most. Clients only use it to request a client key.
-
Both clients and servers access the winbolonetDestroy() function when the application quits.
+
Both clients and servers access the ''winbolonetDestroy();'' function when the application quits.
Line 34: Line 34:
* startTime - Game start time
* startTime - Game start time
*********************************************************/
*********************************************************/
-
bool winbolonetCreateServer(char *mapName, unsigned short port, BYTE gameType, BYTE ai, bool mines, bool password, BYTE numBases, BYTE numPills, BYTE freeBases, BYTE freePills, BYTE numPlayers, long startTime);
+
bool winbolonetCreateServer(char *mapName, unsigned short port, BYTE gameType,
 +
BYTE ai, bool mines, bool password, BYTE numBases, BYTE numPills, BYTE freeBases,
 +
BYTE freePills, BYTE numPlayers, long startTime);
</pre>
</pre>
Line 57: Line 59:
</pre>
</pre>
-
This function is called by a lot of different files in [[bolo]]/ every time a game event occurs. e.g. a pillbox is captured. It adds an event to [[#winbolonetevents.c]] so that it can be processed by [[#winbolowinbolothread.c]].
+
This function is called by a lot of different files in [[bolo]]/ every time a game event occurs. e.g. a pillbox is captured. It adds an event to [[#winbolonetevents.c]] so that it can be processed by [[#winbolowinbolonetthread.c]].
The list of valid eventTypes's are located in winbolonet.h
The list of valid eventTypes's are located in winbolonet.h
Line 99: Line 101:
=== winbolonetthread.c ===
=== winbolonetthread.c ===
-
This file contains the Windows and linux code for creating a new processing thread that periodically (500ms) checks for new pending events that haven't been sent to [[WBN]]. This code was placed in a thread so it could run asynchronously as not lock up the server with WBN was to become unavailable or take a long time to respond to requests.  
+
This file contains the Windows and linux code for creating a new processing thread that periodically (500ms) checks for new pending events that haven't been sent to [[WBN]]. This code was placed in a thread so it could run asynchronously as not lock up the server with WBN was to become unavailable or take a long time to respond to requests.
== http.c ==
== http.c ==
http.c contains the Windows and Linux low level source code for communicating to the WBN server over HTTP. It also provides the log uploading functionality.
http.c contains the Windows and Linux low level source code for communicating to the WBN server over HTTP. It also provides the log uploading functionality.

Current revision

The winbolonet directory contains the code that communicates with WBN using the WBN Protocol.

Contents

winbolonet.c

winbolonet.c is the entry point for code to access winbolo.net. Servers use the module the most. Clients only use it to request a client key.

Both clients and servers access the winbolonetDestroy(); function when the application quits.


Server Functions

/*********************************************************
*NAME:          winbolonetCreateServer
*AUTHOR:        John Morrison
*CREATION DATE: 23/09/01
*LAST MODIFIED: 02/04/02
*PURPOSE:
* Initialises the WinBolo.net module. Returns success.
* Tries to contact server to verify versions.
*
*ARGUMENTS:
* mapName - Name of the map
* port - Port we are running on
* gameType - Game Type
* ai - Is AI allowed
* mines - Mines allowed
* password - Has password
* numBases - Number of bases
* numPills - Number of pills
* freeBases - Free bases
* freePills - Free pills
* numPlayers -  Number of players in the game
* startTime - Game start time
*********************************************************/
bool winbolonetCreateServer(char *mapName, unsigned short port, BYTE gameType,
BYTE ai, bool mines, bool password, BYTE numBases, BYTE numPills, BYTE freeBases,
BYTE freePills, BYTE numPlayers, long startTime);

Used to register a server with WBN.

/*********************************************************
*NAME:          winbolonetAddEvent
*AUTHOR:        John Morrison
*CREATION DATE: 04/04/02
*LAST MODIFIED: 04/04/02
*PURPOSE:
* Adds a WinBolo.net Event for sending to the server
*
*ARGUMENTS:
*  eventType - Type of event this is
*  isServer  - Are we the server for this and not a client
*  playerA   - Player A player Number
*  playerB   - Player B player Number
*********************************************************/
void winbolonetAddEvent(BYTE eventType, bool isServer, BYTE playerA, BYTE playerB);

This function is called by a lot of different files in bolo/ every time a game event occurs. e.g. a pillbox is captured. It adds an event to #winbolonetevents.c so that it can be processed by #winbolowinbolonetthread.c.

The list of valid eventTypes's are located in winbolonet.h

Client Functions

Clients make use of the following functions:

/*********************************************************
*NAME:          winbolonetCreateClient
*AUTHOR:        John Morrison
*CREATION DATE: 31/03/02
*LAST MODIFIED: 31/03/02
*PURPOSE:
* Initialises the WinBolo.net module for a client.
* Returns success.
*
*ARGUMENTS:
* userName  - WinBolo.net account name
* password  - Password for the account
* serverKey - Session key for the server
* errorMsg  - Buffer to hold Error message if required
*********************************************************/
bool winbolonetCreateClient(char *userName, char *password, BYTE *serverKey, char *errorMsg);

winbolonetevents.c

This is a simple linked list class an accessor functions for holding pending WBN events prior to sending them. The underlying list structure is defined as:

typedef struct winboloNetObj *winbolonetEvents;
struct winboloNetObj {
  winbolonetEvents next; /* Next item */
  BYTE itemType;
  BYTE keyA[WINBOLONET_KEY_LEN];
  BYTE keyB[WINBOLONET_KEY_LEN];
};

winbolonetthread.c

This file contains the Windows and linux code for creating a new processing thread that periodically (500ms) checks for new pending events that haven't been sent to WBN. This code was placed in a thread so it could run asynchronously as not lock up the server with WBN was to become unavailable or take a long time to respond to requests.

http.c

http.c contains the Windows and Linux low level source code for communicating to the WBN server over HTTP. It also provides the log uploading functionality.

Personal tools