NDCore Class Reference
Core NetDog object.
More...
List of all members.
Detailed Description
Core NetDog object. This is the "root" of the object hierarchy, and is used to create channels, perform network processing via mainLoop(), etc.
Constructor & Destructor Documentation
Creating an instance of the core initializes NetDog and gives you access to NetDog functions, e.g. allows you to create channels, which in turn allow you to create conns, etc.
- Returns:
- new NDCore object
Member Function Documentation
| NDResult NDCore::cancelScheduledHandler |
( |
void |
|
) |
|
- Returns:
- NDRES_OK if the scheduled function was cancelled successfully
| NDResult NDCore::createChannel |
( |
NDCore::SocketType |
stype, |
|
|
NDChannelID |
channel_id = 0, |
|
|
NDChannel ** |
chan_ptr = NULL, |
|
|
uint16_t |
ip_port = 0 | |
|
) |
| | |
- Parameters:
-
| stype | Determines if this is a UDP or TCP channel, acceptable values are NDCore::UDP or NDCore::TCP |
| channel_id | A network-wide unique integer identifier for the channel. This is user specified, and the meaning is user defined. |
| chan_ptr | Location of the channel pointer that will contain the new NDChannel object. No pointer is passed back if chan_ptr=NULL. |
| ip_port | The UDP port number to accept incomming packets on, uses an OS assigned port number if udp_port=0 |
- Returns:
- NDRES_OK on success
- Example:
NDCore *core = ... //already initialized
NDChannel *chan = NULL;
if(core->createChannelUDP(100, &chan, 0) != NDRES_OK){
// Bail Out
exit(1);
}
// Do stuff with our working channel!
| NDChannel * NDCore::getChannelByID |
( |
NDChannelID |
id |
) |
|
- Parameters:
-
- Returns:
- Pointer to the NDChannel object, or NULL if not found.
| NDTimeValue NDCore::getCoreTime |
( |
void |
|
) |
|
- Returns:
- time in miliseconds
| void NDCore::mainLoop |
( |
NDTimeValue |
timeout = -1 |
) |
|
Executes the main loop of NetDog. This must be called frequently (e.g. at least every 10ms) or network performance may decline, potentially dropping connections. This loop processing all incoming network data, such as events, RPCs, object updates, etc.
- Parameters:
-
| timeout | maximum time in milliseconds to allow this function to run before exiting (e.g. to maintain a certain graphical framerate, etc.) |
- Parameters:
-
| ch | An instance of a class implementing the NDConnHandler interface |
- Returns:
- NDRES_OK if the handler was install successfully
| NDResult NDCore::registerScheduledHandler |
( |
NDScheduledHandler * |
shan, |
|
|
NDTimeValue |
period | |
|
) |
| | |
- Parameters:
-
| shan | An instance of a class which implements the NDScheduledHandler interface |
| period | The interval at which to call the scheduled function, in milliseconds |
- Returns:
- NDRES_OK if the scheduled function was installed successfully