Main Page   Modules   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

GNE Namespace Reference

The namespace in which all of GNE resides in. More...


Compounds

class  Address
class  Buffer
 The Buffer class provides functionality to pull data types out of a raw binary data buffer. More...

class  BufferError
class  ChannelPacket
class  ChannelProvider
struct  ChannelProvider::Channel
class  ClientConnection
class  ClientConnectionParams
 Simply just a class to temporarily hold connection parameters until the ClientConnection is connected, then it is useless. More...

class  ConditionVariable
struct  ConditionVariable::ConditionVariableData
class  Connection
class  Connection::Listener
class  ConnectionEventGenerator
class  ConnectionListener
class  ConnectionParams
struct  ConnectionStats
class  ConsoleBuffer
class  Counter
class  CustomPacket
class  Error
class  EventThread
class  ExitPacket
struct  GNEProtocolVersionNumber
class  ListServerConnection
struct  ListServerConnection::GameListData
 Data about each game. More...

class  Lock
class  LockEx
class  LowLevelError
class  Mutex
struct  Mutex::MutexData
class  NetworkObject
class  NullDeleter
 Deleter that does nothing for the SmartPtr. More...

class  ObjectBroker
class  ObjectBrokerClient
class  ObjectBrokerPacket
class  ObjectBrokerServer
class  ObjectCreationPacket
class  ObjectDeathPacket
class  ObjectUpdatePacket
class  Packet
class  PacketFeeder
class  PacketStream
class  PacketTypeMismatch
struct  PingInformation
class  PingPacket
class  ProtocolViolation
class  RateAdjustPacket
class  ReceiveEventListener
class  SafeCount
class  ServerConnection
class  ServerConnectionListener
class  ServerConnectionListener::ServerListener
class  ServerConnectionParams
 Simply just a class to temporarily hold connection parameters until the ClientConnection is connected, then it is useless. More...

class  SmartPtr
class  SocketPair
class  SyncConnection
class  SynchronizedObject
class  Thread
struct  Thread::ThreadIDData
class  Time
class  Timer
class  TimerCallback
class  UnknownPacket
class  UserError
class  UserVersionMismatch
class  WeakPtr
class  WrapperPacket
class  WrongGame

Typedefs

typedef std::list< Connection
* >::iterator 
ChannelIterator
typedef std::vector< ServerConnectionListener::sptr > SCLList
typedef SCLList::iterator SCLListIter
typedef pthread_t ID
typedef std::map< ID, Thread::sptr > ThreadMap
typedef ThreadMap::iterator ThreadMapIter
typedef signed char gint8
 Typedefs for the variable types that are common to all GNE implementations (as defined in the GNE protocol document).

typedef unsigned char guint8
typedef guint8 gbyte
typedef guint8 gbool
 A gbool is 'false' only when its value is 0, else it is 'true'.

typedef signed short gint16
typedef unsigned short guint16
typedef signed int gint32
typedef unsigned int guint32
typedef float gsingle
 A single precision 32-bit IEEE 754 floating point variable.

typedef double gdouble
 A double precision 64-bit IEEE 754 floating point variable.

typedef Lock< MutexLockMutex
typedef Lock< ConditionVariableLockCV
typedef Lock< SynchronizedObjectLockObject
 Locks a SynchronizedObject.

typedef LockEx< MutexLockMutexEx
typedef LockEx< ConditionVariableLockCVEx
typedef LockEx< SynchronizedObjectLockObjectEx
typedef NetworkObject *(* ObjCreationFunc )(int objectId, const Packet &)

Functions

bool initGNE (NLenum networkType, int(*atexit_ptr)(void(*func)(void)), int timeToClose)
 Initalizes GNE and HawkNL.

void shutdownGNE ()
 Shuts down GNE and HawkNL.

Address getLocalAddress ()
 Use this function to get the address of the default networking device on this system, if possible.

ConnectionStats getGlobalStats ()
 Gets the global stats.

void enableStats ()
 Enables stats gathering, which is off by default.

void disableStats ()
 Disables stats gathering, which is the default mode.

void clearStats ()
 Clears all global stats.

int getOpenConnections ()
 Returns the number of open low-level connections GNE has opened.

GNEProtocolVersionNumber getGNEProtocolVersion ()
 Returns the GNE Protocol version number.

const char * getGameName ()
 This function is used internally by GNE to get the name that you set in setGameInformation.

guint32 getUserVersion ()
 This function is used internally by GNE to get the version that you set in setGameInformation.

void setGameInformation (std::string gameName, guint32 version)
 The user's game information.

void checkVersions (const GNEProtocolVersionNumber &otherGNE, std::string otherName, guint32 otherUser)
 Compares other versions against this library.

bool initDebug (int levelMask, const char *fileName=NULL)
 Function to initalize debugging.

void killDebug ()
 Function to deinitialize debugging.

void doTrace (int level, const char *fn, int lineno, const char *msg,...)
 A function available in a debug compile that does trace logging to a file.

template<class T> void swap (SmartPtr< T > &a, SmartPtr< T > &b)
template<class T, class U> SmartPtr< T > static_pointer_cast (SmartPtr< U > const &r)
template<class T, class U> SmartPtr< T > dynamic_pointer_cast (SmartPtr< U > const &r)
template<class T> void swap (WeakPtr< T > &a, WeakPtr< T > &b)

Variables

const int MINLEN = 8
const int REFLEN = 44
const int CAPLEN = 12
const std::string ErrorStrings []
const std::string ViolationStrings []
char gameNameBuf [32] = {0}
guint32 userVersion = 0
ConnectionEventGenerator::sptr eGen
 The global event generator.

const int CRPLEN = 48
const int MAX_GAME_NAME_LEN = 31
 The maximum number of ASCII characters in game name that is passed into the setGameInformation function.

const double VER = 0.70
 A numeric representation of the current version of this library.

const std::string VER_STR = "GNE v0.70"
 A string representation of the name of the library and the current version.

const int UDP_HEADER_SIZE = 28
 The low-level header size of a UDP header, which is used with the HawkNL internet driver that GNE uses.

const NLenum NO_NET = 128
 Normally you would pass a network type to GNE::init, but passing this value means that no network should be initalized.

const int DLEVEL1 = 1
 Debugging level constants for the levelMask.

const int DLEVEL2 = 2
const int DLEVEL3 = 4
const int DLEVEL4 = 8
const int DLEVEL5 = 16
const gbool gTrue = 1
 One possible true value for a gbool.

const gbool gFalse = 0
 The only false value for a gbool.


Detailed Description

The namespace in which all of GNE resides in.

The namespace consists of a few global functions, some constants, classes, and the GNE::Console namespace, which holds the console IO functions.


Typedef Documentation

typedef signed char GNE::gint8
 

Typedefs for the variable types that are common to all GNE implementations (as defined in the GNE protocol document).

"u" type variables denote unsigned versions.

typedef Lock<SynchronizedObject> GNE::LockObject
 

Locks a SynchronizedObject.

The Console::gout object is such an example. You can use LockObject lock(gout); as a safer alternative to the stream manipulators Console::acquire and Console::release.


Function Documentation

void GNE::checkVersions const GNEProtocolVersionNumber &  otherGNE,
std::string  otherName,
guint32  otherUser
 

Compares other versions against this library.

This is used internally by GNE to compare versions. It checks the GNE version numbers first, then the game name, then the user versions.

Exceptions:
Error if the GNE versions did not match.
WrongGame if the game is of the wrong type.
UserVersionMismatch if the user versions are different.

void doTrace int  level,
const char *  fn,
int  lineno,
const char *  msg,
... 
 

A function available in a debug compile that does trace logging to a file.

This function is thread-safe.

Parameters:
level the "level" of detail for this trace statement, 1 being the most basic and should always be displayed. The higher you go, the more detailed the trace should get. This is so to allow debugging but not totally flood the logfile unless you need to get this detailed.
These general standards are followed:
1 - startup, shutdown, and explicit error messages.
2 - connection, disconnection, and other "normal" operation.
3 - average level. packet registration, socket registration
4 - events like onReceive and such, and some reporting.
5 - very low level -- thread creation, memory allocation.
fn The file name this trace was called from
lineno The line number in the file
msg The message to display to the logfile, in printf style, followed by the data.

void GNE::enableStats  ) 
 

Enables stats gathering, which is off by default.

When stats is not enabled, the get function's results is undefined.

ConnectionStats GNE::getGlobalStats  ) 
 

Gets the global stats.

Very similar to Connection::getStats, but this gets cumulative stats for all sockets, user-created ones and GNE ones too you may not know about.

GNEProtocolVersionNumber GNE::getGNEProtocolVersion  ) 
 

Returns the GNE Protocol version number.

This is different from the library version number. This number is specified by the GNE protocol document on the GNE web site. Versions of this library obtained from CVS might have the build number non-zero. Non-beta public releases of GNE will have a build number of zero and a version and subVersion number strictly defined by the GNE protocol specification. Public alpha or beta releases might have a non-zero build number.

Address GNE::getLocalAddress  ) 
 

Use this function to get the address of the default networking device on this system, if possible.

The port in the resulting address will be zero. The returned address is invalid if an error occured.

bool initDebug int  levelMask,
const char *  fileName = NULL
 

Function to initalize debugging.

This is safe to call before initialization of GNE, but can be called at any time (but not multiple times). No debugging messages will be displayed until this function is called, and it is save to use the debugging macros and doTrace before calling this -- just nothing will be displayed.

Parameters:
fileName an optional fileName to log to. If you pass NULL for this parameter, then GNE will pick a temp file name that is safe for multiple instances. The filename will be based on time: gneHH'MM'SS.log
levelMask sets just how detailed the trace is, and will display all messages that match this parameter. You should bitwise OR together the levels you want to see.
Returns:
false on error

bool GNE::initGNE NLenum  networkType,
int(*  atexit_ptr)(void(*func)(void)),
int  timeToClose = 10000
 

Initalizes GNE and HawkNL.

Call this before using any HawkNL or GNE functions. Pass it the atexit function so shutdown will be called on exit. A call to any other GNE function before this function succeeds is undefined.

Neither initGNE nor shutdownGNE calls are thread-safe, so they should only be called by the main thread.

Parameters:
networkType a HawkNL network driver, such as NL_IP or NL_IPX. I've only ever tested NL_IP.
timeToClose the amount of time in milliseconds to wait for connections to finish closing, timers to shut down, and user threads to close.
Returns:
true if GNE or HawkNL could not be initalized.
See also:
shutdownGNE

void killDebug  ) 
 

Function to deinitialize debugging.

This will be called automatically on program exit, and the GNE user need not call it.

void GNE::setGameInformation std::string  gameName,
guint32  version
 

The user's game information.

This information is used during the connection process to check if the versions and games match. This function should only be called once before making any connections.

Parameters:
gameName the name of your game, or any other unique string identifier in ASCII format with a length not exceeding MAX_GAME_NAME_LEN ASCII characters.
version a 4-byte value with the current game version in any format.

void GNE::shutdownGNE  ) 
 

Shuts down GNE and HawkNL.

All open connections will be closed, all active timers will be shut down, and the shutDown method of all of the threads you have created will be called. The method will block for the time passed into the initGNE function. After that time has passed, the shutdown function exits. If it is being called as a result of the atexit procedure, the process will be forcefully shutdown when the atexit handlers quit, so a stalled/crashed thread won't keep the program from shutting down, but it will keep destructors from being called.

Note that if you have connections, timers, or threads running when main ends, you can be running code or be receiving events after the main function has ended. If this will be a problem you should explicitly call the shutdownGNE method.

Neither initGNE nor shutdownGNE calls are thread-safe, so they should only be called by the main thread, and most certainly not from any GNE Thread (this also means you cannot call "exit" from a GNE Thread).


Variable Documentation

SmartPtr< ConnectionEventGenerator > GNE::eGen
 

The global event generator.

The library uses this internally to register and unregister connections. The end-user will not have to use this object under any normal cirumstances.

const std::string GNE::ErrorStrings[]
 

Initial value:

 {
  "No error.",
  "The remote end did not follow the specifications of the GNE protocol.",
  "The remote end uses an earlier version of the GNE protocol.",
  "The remote end uses a later version of the GNE protocol.",
  "The connecting game names differ.",
  "The user protocol version numbers do not match.",
  "Could not open a network socket.",
  "Could not contact the host due to connection timeout.",
  "The connection attempt was aborted.",
  "The remote end decided to refuse your connection request.",
  "Remote computer suddenly disconnected without warning, or dropped.",
  "The operation was canceled because the SyncConnection is released.",
  "The remote end sent a connection close notice.",
  "Network error when trying to read from connection.",
  "Network error when trying to write to connection.",
  "Unknown packet type encountered -- possible additional data loss.",
  "Packet type received does not match next packet type expected.",
  "An object with the given ID already exists.",
  "The given object ID does not match a known object.",
  "A packet of the wrong type was passed to the ObjectBroker.",
  "The packet ID is not registered as a valid object creation packet.",
  "Buffer underflow error (attempt to read more bytes than available).",
  "Buffer overflow error (attempt to write more bytes than the buffer can hold).",
  "An invalid value for position was given to Buffer::setPosition",
  "An invalid value for limit was given to Buffer::setLimit",
  "Other GNE (not a low-level network) error.",
  "Low-level HawkNL error:",
  "User-defined Error"
}

const NLenum GNE::NO_NET = 128
 

Normally you would pass a network type to GNE::init, but passing this value means that no network should be initalized.

This is useful only in the example programs that don't use networking and do not need to initalize everything.

See also:
initGNE

const int GNE::UDP_HEADER_SIZE = 28
 

The low-level header size of a UDP header, which is used with the HawkNL internet driver that GNE uses.

A number that I always have trouble finding and might be useful in getting stats or calculating actual bandwith.

const std::string GNE::ViolationStrings[]
 

Initial value:

 {
  "",
  " Client sent an invalid request packet.",
  " Server sent an invalid connection response packet.",
  " Client sent an invalid or corrupted unreliable information packet."
}


Generated on Fri Aug 22 13:40:05 2003 for GNE by doxygen1.3