Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# XFuInetNetwork Class Reference

Default implementation for a communication manager. More...

`#include <XFuInetNetwork.h>`

Inheritance diagram for XFuInetNetwork:

[legend]
Collaboration diagram for XFuInetNetwork:

[legend]
List of all members.

## Public Member Functions
virtual | ~XFuInetNetwork ()
| Destructor.
virtual void | reset ()
| Resets the communication manager.
virtual void | runCommunicationScheduler ()
| Runs the communication scheduler.
virtual void | clientLost (INT32 aClientId)
| Connection lost handler (XFuClientLost) (callback).
virtual INT | handleSender (const void *aAddress, const CHAR8 *aData, INT32 aLen)
| Handle data from an unknown client (callback).
virtual INT | enableService (INT32 aMaxClients, UINT16 aPort, INT32 aDefaultSpeed)
| Enables the inet communication handler and opens it for service.
virtual void | closeService ()
| Closes the currently active service (communication handler).
virtual XFcClientCommWin * | getClient (INT32 aClientId)
| Returns the specified client.
virtual INT32 | addClient (XFcAddress *aAddress, INT32 aTimeoutTime=15000)
| Adds a client with the specific address.
virtual void | removeClient (INT32 aClientId)
| Removes the specified client.
virtual void | removeAllClients ()
| Removes all clients.
virtual UINT32 | getAcceptGameToken ()
| Returns the game token that is checked before new clients are allowed to connect.
virtual void | setAcceptGameToken (UINT32 aAcceptGameToken)
| Sets the game token that is checked before new clients are allowed to connect.
virtual void | sendGameConnectPacket (INT32 aClientId, UINT32 aGameToken)
| Sends a game connection packet.
virtual XFcDataReceiver * | getDefaultDataReceiver ()
| Returns a pointer to the default data receiver.
virtual void | setDefaultDataReceiver (XFcDataReceiver *aReceiver)
| Sets the default data receiver.
virtual XFcDataReceiver * | getDataReceiver (UINT32 aId)
| Returns the specified data receiver.
virtual INT | addDataReceiver (UINT32 aId, XFcDataReceiver *aReceiver)
| Adds a new data receiver.
virtual XFcDataReceiver * | removeDataReceiver (UINT32 aId)
| Removes a data receiver.
virtual INT32 | getRoundTripTime (INT32 aClientId)
| Returns the round trip time for the specified client.
virtual XFcObjectDataFrame * | getPacketFrame (INT32 aClientId, XFCNET_MESSAGE_SLOT aSlot)
| Get packet frame.
virtual XFcObjectDataFrame * | getRecentStateFrame (INT32 aClientId, INT32 aRecentId)
| Get recent state frame.
virtual void | removeRecentStateFrame (INT32 aClientId, INT32 aRecentId)
| Remove recent state frame.
virtual INT32 | send (INT32 aClientId, UINT32 aReceiverId, XFCNET_MESSAGE_SLOT aSlot, XFuSerializable *aSerializable)
| Sends a serializable object to the specified client.
virtual INT32 | sendRecentState (INT32 aClientId, UINT32 aReceiverId, INT32 aRecentId, XFuSerializable *aSerializable)
| Sends a serializable object to the specified client as a recent state packet.
virtual void | addEventHandler (XFuNetworkEventHandler *aHandler)
| Adds a communication event handler.
virtual void | removeEventHandler (XFuNetworkEventHandler *aHandler)
| Removes a communication event handler.
virtual void | removeAllEventHandlers ()
| Removes all communication event handlers.
virtual INT | startAdvertiser (const CHAR8 *aMessage, UINT16 aAdvertisePort)
| Cretes advertiser for opened service.
virtual void | stopAdvertiser ()
| Stops the advertiser service.
virtual INT | startServerDiscovery (const CHAR8 *aMessage, UINT16 aAdvertisePort)
| Starts server device discovery.
virtual void | stopServerDiscovery ()
| Stops device discovery.
virtual void | deviceDiscovery (const XFcLinkedList< XFcAdvertiser * > &aAdvertiser)
| Inherited from XFcDeviceDiscovery.
virtual void | deviceDiscovery (const XFcLinkedList< XFcHostEntry * > &)
| Inherited from XFcDeviceDiscovery.
virtual INT | deviceLocalName (XFcName &aName)
| Gets device local name.
## Static Public Member Functions
XFuInetNetwork * | create ()
| Static constructor.
## Protected Member Functions
| XFuInetNetwork ()
| Protected constructor.
virtual void | initClients (INT32 aMaxClients)
| Reserves memory for the client array (mClients) and initializes all the client pointers to NULL.
virtual void | deleteAllClients ()
| Cleanup of all clients.
virtual INT | init ()
| Initializes default communication manager specific items that would normally be in the constructor.
## Private Attributes
XFuDynamicArray< XFuNetworkEventHandler * > * | mNetworkEventHandlers
| Pointer to array of communication event handlers.
XFcCommunicationScheduler * | mCommunicationScheduler
| Pointer to the communication scheduler.
XFcInetHandler * | mCommunicationHandler
| Pointer to the communication handler.
XFcDataReceiver * | mDefaultDataReceiver
| Pointer to the default data receiver.
INT32 | mCommunicationHandlerId
| Id of the communication handler.
XFcHashtable< UINT32, XFcInetClientWin * > | mClients
| Array of pointers to clients.
INT32 | mMaxClients
| Maximum number of clients.
UINT32 | mAcceptGameToken
| Game token that is checked before new clients are allowed to connect.
INT | mAdvertiserStatus
| Holds status of advertiser device query.
UINT16 | mGamePort
| Holds inet server port.
XFcInetHostResolver * | mHostResolver
| Pointer to the communication service.
XFcInetCommService * | mCommService
| Pointer to the inet communication service.

## Detailed Description

Default implementation for a communication manager.

Definition at line 44 of file XFuInetNetwork.h.

## Constructor & Destructor Documentation

XFuInetNetwork::XFuInetNetwork | ( |  | ) | `[protected]`

| Protected constructor. Definition at line 51 of file XFuInetNetwork.cpp. References mAcceptGameToken, mAdvertiserStatus, mCommService, mCommunicationHandler, mCommunicationHandlerId, mCommunicationScheduler, mHostResolver, mMaxClients, and mNetworkEventHandlers.

XFuInetNetwork::~XFuInetNetwork | ( |  | ) | `[virtual]`

| Destructor. Definition at line 71 of file XFuInetNetwork.cpp. References closeService(), deleteAllClients(), mCommService, mCommunicationHandler, mHostResolver, mNetworkEventHandlers, and removeAllEventHandlers().

## Member Function Documentation

INT32 XFuInetNetwork::addClient | ( | XFcAddress * | aAddress,
|  | INT32 | aTimeoutTime = 15000
| ) | `[virtual]`

| Adds a client with the specific address. Returns: The client id or XFCNET_CLIENTADD_ERROR if failed. Implements XFuNetwork. Definition at line 333 of file XFuInetNetwork.cpp. References mClients, and mCommunicationScheduler. Referenced by handleSender().

INT XFuInetNetwork::addDataReceiver | ( | UINT32 | aId,
|  | XFcDataReceiver * | aReceiver
| ) | `[virtual]`

| Adds a new data receiver. Implements XFuNetwork. Definition at line 280 of file XFuInetNetwork.cpp. References mCommunicationScheduler.

void XFuInetNetwork::addEventHandler | ( | XFuNetworkEventHandler * | aHandler | ) | `[virtual]`

| Adds a communication event handler. Implements XFuNetwork. Definition at line 294 of file XFuInetNetwork.cpp. References mNetworkEventHandlers, and XFuDynamicArray< XFuNetworkEventHandler * >::put().

void XFuInetNetwork::clientLost | ( | INT32 | aClientId | ) | `[virtual]`

| Connection lost handler (XFuClientLost) (callback). Definition at line 445 of file XFuInetNetwork.cpp. References XFuDynamicArray< XFuNetworkEventHandler * >::get(), XFuNetworkEventHandler::handleClientLost(), mNetworkEventHandlers, removeClient(), and XFuDynamicArray< XFuNetworkEventHandler * >::size().

void XFuInetNetwork::closeService | ( |  | ) | `[virtual]`

| Closes the currently active service (communication handler). Implements XFuNetwork. Definition at line 158 of file XFuInetNetwork.cpp. References mCommService, mCommunicationHandler, mCommunicationScheduler, mHostResolver, stopAdvertiser(), and stopServerDiscovery(). Referenced by enableService(), reset(), and ~XFuInetNetwork().

XFuInetNetwork * XFuInetNetwork::create | ( |  | ) | `[static]`

| Static constructor. Definition at line 38 of file XFuInetNetwork.cpp. References init().

void XFuInetNetwork::deleteAllClients | ( |  | ) | `[protected, virtual]`

| Cleanup of all clients. Definition at line 222 of file XFuInetNetwork.cpp. References getClient(), mClients, and mCommunicationScheduler. Referenced by ~XFuInetNetwork().

virtual void XFuInetNetwork::deviceDiscovery | ( | const XFcLinkedList< XFcHostEntry * > & |  | ) | `[inline, virtual]`

| Inherited from XFcDeviceDiscovery. Definition at line 220 of file XFuInetNetwork.h.

void XFuInetNetwork::deviceDiscovery | ( | const XFcLinkedList< XFcAdvertiser * > & | aAdvertiser | ) | `[virtual]`

| Inherited from XFcDeviceDiscovery. Definition at line 558 of file XFuInetNetwork.cpp. References XFuDynamicArray< XFuNetworkEventHandler * >::get(), XFuNetworkEventHandler::handleAdvertiseDiscovered(), mNetworkEventHandlers, and XFuDynamicArray< XFuNetworkEventHandler * >::size().

INT XFuInetNetwork::deviceLocalName | ( | XFcName & | aName | ) | `[virtual]`

| Gets device local name. Definition at line 582 of file XFuInetNetwork.cpp. References mHostResolver.

INT XFuInetNetwork::enableService | ( | INT32 | aMaxClients,
|  | UINT16 | aPort,
|  | INT32 | aDefaultSpeed
| ) | `[virtual]`

| Enables the inet communication handler and opens it for service. Use port 0 for random port. Default speed is one of the XFuNET_CONNECTION_SPEED values (see XFcClientCommWin.h) Definition at line 123 of file XFuInetNetwork.cpp. References closeService(), initClients(), mCommService, mCommunicationHandler, mCommunicationHandlerId, mCommunicationScheduler, mGamePort, and removeAllClients().

UINT32 XFuInetNetwork::getAcceptGameToken | ( |  | ) | `[virtual]`

| Returns the game token that is checked before new clients are allowed to connect. Definition at line 181 of file XFuInetNetwork.cpp. References mAcceptGameToken.

XFcClientCommWin * XFuInetNetwork::getClient | ( | INT32 | aClientId | ) | `[virtual]`

| Returns the specified client. Implements XFuNetwork. Definition at line 315 of file XFuInetNetwork.cpp. References mClients. Referenced by deleteAllClients(), and removeClient().

XFcDataReceiver * XFuInetNetwork::getDataReceiver | ( | UINT32 | aId | ) | `[virtual]`

| Returns the specified data receiver. Implements XFuNetwork. Definition at line 273 of file XFuInetNetwork.cpp. References mCommunicationScheduler.

XFcDataReceiver * XFuInetNetwork::getDefaultDataReceiver | ( |  | ) | `[virtual]`

| Returns a pointer to the default data receiver. Implements XFuNetwork. Definition at line 258 of file XFuInetNetwork.cpp. References mDefaultDataReceiver.

XFcObjectDataFrame * XFuInetNetwork::getPacketFrame | ( | INT32 | aClientId,
|  | XFCNET_MESSAGE_SLOT | aSlot
| ) | `[virtual]`

| Get packet frame. Implements XFuNetwork. Definition at line 383 of file XFuInetNetwork.cpp. References mCommunicationScheduler. Referenced by send(), and sendGameConnectPacket().

XFcObjectDataFrame * XFuInetNetwork::getRecentStateFrame | ( | INT32 | aClientId,
|  | INT32 | aRecentId
| ) | `[virtual]`

| Get recent state frame. Implements XFuNetwork. Definition at line 390 of file XFuInetNetwork.cpp. References mCommunicationScheduler. Referenced by sendRecentState().

INT32 XFuInetNetwork::getRoundTripTime | ( | INT32 | aClientId | ) | `[virtual]`

| Returns the round trip time for the specified client. Definition at line 376 of file XFuInetNetwork.cpp. References mCommunicationScheduler.

INT XFuInetNetwork::handleSender | ( | const void * | aAddress,
|  | const CHAR8 * | aData,
|  | INT32 | aLen
| ) | `[virtual]`

| Handle data from an unknown client (callback). Definition at line 458 of file XFuInetNetwork.cpp. References addClient(), XFuDynamicArray< XFuNetworkEventHandler * >::get(), XFuNetworkEventHandler::handleClientAccepted(), mAcceptGameToken, mNetworkEventHandlers, and XFuDynamicArray< XFuNetworkEventHandler * >::size().

INT XFuInetNetwork::init | ( |  | ) | `[protected, virtual]`

| Initializes default communication manager specific items that would normally be in the constructor. Definition at line 86 of file XFuInetNetwork.cpp. References XFuDynamicArray< T >::create(), mCommunicationScheduler, and mNetworkEventHandlers. Referenced by create(), and reset().

void XFuInetNetwork::initClients | ( | INT32 | aMaxClients | ) | `[protected, virtual]`

| Reserves memory for the client array (mClients) and initializes all the client pointers to NULL. Reserves memory for the client array (mClients) and initializes all the client pointers to NULL Definition at line 215 of file XFuInetNetwork.cpp. References mMaxClients. Referenced by enableService().

void XFuInetNetwork::removeAllClients | ( |  | ) | `[virtual]`

| Removes all clients. Implements XFuNetwork. Definition at line 240 of file XFuInetNetwork.cpp. References mClients, mCommunicationHandler, and removeClient(). Referenced by enableService(), and reset().

void XFuInetNetwork::removeAllEventHandlers | ( |  | ) | `[virtual]`

| Removes all communication event handlers. Implements XFuNetwork. Definition at line 308 of file XFuInetNetwork.cpp. References XFuDynamicArray< XFuNetworkEventHandler * >::isEmpty(), mNetworkEventHandlers, and XFuDynamicArray< XFuNetworkEventHandler * >::remove(). Referenced by reset(), and ~XFuInetNetwork().

void XFuInetNetwork::removeClient | ( | INT32 | aClientId | ) | `[virtual]`

| Removes the specified client. Implements XFuNetwork. Definition at line 359 of file XFuInetNetwork.cpp. References getClient(), mClients, mCommunicationHandler, and mCommunicationScheduler. Referenced by clientLost(), and removeAllClients().

XFcDataReceiver * XFuInetNetwork::removeDataReceiver | ( | UINT32 | aId | ) | `[virtual]`

| Removes a data receiver. Implements XFuNetwork. Definition at line 287 of file XFuInetNetwork.cpp. References mCommunicationScheduler.

void XFuInetNetwork::removeEventHandler | ( | XFuNetworkEventHandler * | aHandler | ) | `[virtual]`

| Removes a communication event handler. Implements XFuNetwork. Definition at line 301 of file XFuInetNetwork.cpp. References mNetworkEventHandlers, and XFuDynamicArray< XFuNetworkEventHandler * >::remove().

void XFuInetNetwork::removeRecentStateFrame | ( | INT32 | aClientId,
|  | INT32 | aRecentId
| ) | `[virtual]`

| Remove recent state frame. Implements XFuNetwork. Definition at line 397 of file XFuInetNetwork.cpp. References mCommunicationScheduler.

void XFuInetNetwork::reset | ( |  | ) | `[virtual]`

| Resets the communication manager. Definition at line 109 of file XFuInetNetwork.cpp. References closeService(), init(), mAcceptGameToken, mMaxClients, removeAllClients(), and removeAllEventHandlers().

void XFuInetNetwork::runCommunicationScheduler | ( |  | ) | `[virtual]`

| Runs the communication scheduler. Implements XFuNetwork. Definition at line 102 of file XFuInetNetwork.cpp. References mCommunicationScheduler.

INT32 XFuInetNetwork::send | ( | INT32 | aClientId,
|  | UINT32 | aReceiverId,
|  | XFCNET_MESSAGE_SLOT | aSlot,
|  | XFuSerializable * | aSerializable
| ) | `[virtual]`

| Sends a serializable object to the specified client. Definition at line 404 of file XFuInetNetwork.cpp. References getPacketFrame(), and XFuSerializable::serialize().

void XFuInetNetwork::sendGameConnectPacket | ( | INT32 | aClientId,
|  | UINT32 | aGameToken
| ) | `[virtual]`

| Sends a game connection packet. Definition at line 194 of file XFuInetNetwork.cpp. References getPacketFrame().

INT32 XFuInetNetwork::sendRecentState | ( | INT32 | aClientId,
|  | UINT32 | aReceiverId,
|  | INT32 | aRecentId,
|  | XFuSerializable * | aSerializable
| ) | `[virtual]`

| Sends a serializable object to the specified client as a recent state packet. Definition at line 425 of file XFuInetNetwork.cpp. References getRecentStateFrame(), and XFuSerializable::serialize().

void XFuInetNetwork::setAcceptGameToken | ( | UINT32 | aAcceptGameToken | ) | `[virtual]`

| Sets the game token that is checked before new clients are allowed to connect. Definition at line 187 of file XFuInetNetwork.cpp. References mAcceptGameToken.

void XFuInetNetwork::setDefaultDataReceiver | ( | XFcDataReceiver * | aReceiver | ) | `[virtual]`

| Sets the default data receiver. Implements XFuNetwork. Definition at line 265 of file XFuInetNetwork.cpp. References mCommunicationScheduler, and mDefaultDataReceiver.

INT XFuInetNetwork::startAdvertiser | ( | const CHAR8 * | aMessage,
|  | UINT16 | aAdvertisePort
| ) | `[virtual]`

  | Cretes advertiser for opened service. Parameters:
  aMessage | message to be sent to the receiver of the advertise, or NULL to use the default message.
  aAdvertisePort | port where advertiser is created and for bt its 0.
Returns: 1 if advertiser service starts successfully, or XFCNET_ERROR otherwise. Definition at line 523 of file XFuInetNetwork.cpp. References mCommService.

INT XFuInetNetwork::startServerDiscovery | ( | const CHAR8 * | aMessage,
|  | UINT16 | aAdvertisePort
| ) | `[virtual]`

  | Starts server device discovery. Parameters:
  aMessage | message to be sent to the receiver of the advertise, or NULL to use the default message.
  aAdvertisePort | port where advertiser is created and for bt its 0.
Returns: 1 if discovery starts successfully, or XFCNET_ERROR otherwise. Definition at line 488 of file XFuInetNetwork.cpp. References mCommService.

void XFuInetNetwork::stopAdvertiser | ( |  | ) | `[virtual]`

| Stops the advertiser service. Definition at line 549 of file XFuInetNetwork.cpp. References mCommService. Referenced by closeService().

void XFuInetNetwork::stopServerDiscovery | ( |  | ) | `[virtual]`

| Stops device discovery. Definition at line 516 of file XFuInetNetwork.cpp. References mCommService. Referenced by closeService().

## Member Data Documentation

UINT32 XFuInetNetwork::mAcceptGameToken`[private]`

| Game token that is checked before new clients are allowed to connect. Definition at line 73 of file XFuInetNetwork.h. Referenced by getAcceptGameToken(), handleSender(), reset(), setAcceptGameToken(), and XFuInetNetwork().

INT XFuInetNetwork::mAdvertiserStatus`[private]`

| Holds status of advertiser device query. Definition at line 76 of file XFuInetNetwork.h. Referenced by XFuInetNetwork().

XFcHashtable<UINT32, XFcInetClientWin *> XFuInetNetwork::mClients`[private]`

| Array of pointers to clients. Definition at line 67 of file XFuInetNetwork.h. Referenced by addClient(), deleteAllClients(), getClient(), removeAllClients(), and removeClient().

XFcInetCommService* XFuInetNetwork::mCommService`[private]`

| Pointer to the inet communication service. Definition at line 85 of file XFuInetNetwork.h. Referenced by closeService(), enableService(), startAdvertiser(), startServerDiscovery(), stopAdvertiser(), stopServerDiscovery(), XFuInetNetwork(), and ~XFuInetNetwork().

XFcInetHandler* XFuInetNetwork::mCommunicationHandler`[private]`

| Pointer to the communication handler. Definition at line 58 of file XFuInetNetwork.h. Referenced by closeService(), enableService(), removeAllClients(), removeClient(), XFuInetNetwork(), and ~XFuInetNetwork().

INT32 XFuInetNetwork::mCommunicationHandlerId`[private]`

| Id of the communication handler. Definition at line 64 of file XFuInetNetwork.h. Referenced by enableService(), and XFuInetNetwork().

XFcCommunicationScheduler* XFuInetNetwork::mCommunicationScheduler`[private]`

| Pointer to the communication scheduler. Definition at line 55 of file XFuInetNetwork.h. Referenced by addClient(), addDataReceiver(), closeService(), deleteAllClients(), enableService(), getDataReceiver(), getPacketFrame(), getRecentStateFrame(), getRoundTripTime(), init(), removeClient(), removeDataReceiver(), removeRecentStateFrame(), runCommunicationScheduler(), setDefaultDataReceiver(), and XFuInetNetwork().

XFcDataReceiver* XFuInetNetwork::mDefaultDataReceiver`[private]`

| Pointer to the default data receiver. Definition at line 61 of file XFuInetNetwork.h. Referenced by getDefaultDataReceiver(), and setDefaultDataReceiver().

UINT16 XFuInetNetwork::mGamePort`[private]`

| Holds inet server port. Definition at line 79 of file XFuInetNetwork.h. Referenced by enableService().

XFcInetHostResolver* XFuInetNetwork::mHostResolver`[private]`

| Pointer to the communication service. Definition at line 82 of file XFuInetNetwork.h. Referenced by closeService(), deviceLocalName(), XFuInetNetwork(), and ~XFuInetNetwork().

INT32 XFuInetNetwork::mMaxClients`[private]`

| Maximum number of clients. Definition at line 70 of file XFuInetNetwork.h. Referenced by initClients(), reset(), and XFuInetNetwork().

XFuDynamicArray<XFuNetworkEventHandler*>* XFuInetNetwork::mNetworkEventHandlers`[private]`

| Pointer to array of communication event handlers. Definition at line 52 of file XFuInetNetwork.h. Referenced by addEventHandler(), clientLost(), deviceDiscovery(), handleSender(), init(), removeAllEventHandlers(), removeEventHandler(), XFuInetNetwork(), and ~XFuInetNetwork().

The documentation for this class was generated from the following files:

- XFuInetNetwork.h
- XFuInetNetwork.cpp

|  | X-Forge Documentation Confidential Copyright © 2002-2003 Fathammer |  | Documentation generated with doxygen by Dimitri van Heesch