SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
SLNet::NetworkIDObject Class Reference

Unique shared ids for each object instance. More...

`#include <slikenet/NetworkIDObject.h>`

Inheritance diagram for SLNet::NetworkIDObject:

## Public Member Functions

| NetworkIDObject ()
virtual | ~NetworkIDObject ()
virtual void | SetNetworkIDManager (NetworkIDManager *manager)
virtual NetworkIDManager * | GetNetworkIDManager (void) const
| Returns what was passed to SetNetworkIDManager.
virtual NetworkID | GetNetworkID (void)
virtual void | SetNetworkID (NetworkID id)
virtual void | SetParent (void *_parent)
virtual void * | GetParent (void) const

## Protected Attributes

NetworkID | networkID
| The network ID of this object.
NetworkIDManager * | networkIDManager
void * | parent
| The parent set by SetParent()
NetworkIDObject * | nextInstanceForNetworkIDManager

## Detailed Description

Unique shared ids for each object instance.

A class you can derive from to make it easier to represent every networked object with an integer. This way you can refer to objects over the network. One system should return true for IsNetworkIDAuthority() and the rest should return false. When an object needs to be created, have the the one system create the object. Then have that system send a message to all other systems, and include the value returned from GetNetworkID() in that packet. All other systems should then create the same class of object, and call SetNetworkID() on that class with the NetworkID in the packet.

See Also
  the manual for more information on this.

Definition at line 41 of file NetworkIDObject.h.

## Constructor & Destructor Documentation

NetworkIDObject::NetworkIDObject | ( |  | ) |

Definition at line 27 of file NetworkIDObject.cpp.

References networkID, networkIDManager, nextInstanceForNetworkIDManager, parent, and SLNet::UNASSIGNED_NETWORK_ID.

NetworkIDObject::~NetworkIDObject | ( |  | ) |

virtual

Definition at line 34 of file NetworkIDObject.cpp.

References networkIDManager, and SLNet::NetworkIDManager::StopTrackingNetworkIDObject().

## Member Function Documentation

NetworkID NetworkIDObject::GetNetworkID | ( | void |  | ) |

virtual

Returns the NetworkID that you can use to refer to this object over the network.

Precondition
  You must first call SetNetworkIDManager before using this function

Return values

  UNASSIGNED_NETWORK_ID | UNASSIGNED_NETWORK_ID is returned IsNetworkIDAuthority() is false and SetNetworkID() was not previously called. This is also returned if you call this function in the constructor.
  0-65534 | Any other value is a valid NetworkID. NetworkIDs start at 0 and go to 65534, wrapping at that point.

Definition at line 66 of file NetworkIDObject.cpp.

References networkID.

Referenced by SLNet::NetworkIDManager::GET_BASE_OBJECT_FROM_ID(), SLNet::NetworkIDManager::StopTrackingNetworkIDObject(), and SLNet::NetworkIDManager::TrackNetworkIDObject().

NetworkIDManager * NetworkIDObject::GetNetworkIDManager | ( | void |  | ) | const

virtual

Returns what was passed to SetNetworkIDManager.

Definition at line 62 of file NetworkIDObject.cpp.

References networkIDManager.

Referenced by SLNet::NetworkIDManager::StopTrackingNetworkIDObject(), and SLNet::NetworkIDManager::TrackNetworkIDObject().

void * NetworkIDObject::GetParent | ( | void |  | ) | const

virtual

Return what was passed to SetParent

Returns
  The value passed to SetParent, or 0 if it was never called.

Definition at line 93 of file NetworkIDObject.cpp.

References parent.

Referenced by SLNet::NetworkIDManager::GET_OBJECT_FROM_ID().

void NetworkIDObject::SetNetworkID | ( | NetworkID | id | ) |

virtual

Sets the NetworkID for this instance. Usually this is called by the clients and determined from the servers. However, if you save multiplayer games you would likely use This on load as well.

Definition at line 70 of file NetworkIDObject.cpp.

References networkID, networkIDManager, SetNetworkIDManager(), SLNet::NetworkIDManager::StopTrackingNetworkIDObject(), SLNet::NetworkIDManager::TrackNetworkIDObject(), and SLNet::UNASSIGNED_NETWORK_ID.

void NetworkIDObject::SetNetworkIDManager | ( | NetworkIDManager * | manager | ) |

virtual

Sets the manager class from which to request unique network IDs Unlike previous versions, the NetworkIDObject relies on a manager class to provide IDs, rather than using statics, So you can have more than one set of IDs on the same system.

Definition at line 39 of file NetworkIDObject.cpp.

References SLNet::NetworkIDManager::GetNewNetworkID(), networkID, networkIDManager, SLNet::NetworkIDManager::StopTrackingNetworkIDObject(), SLNet::NetworkIDManager::TrackNetworkIDObject(), and SLNet::UNASSIGNED_NETWORK_ID.

Referenced by SetNetworkID().

void NetworkIDObject::SetParent | ( | void * | _parent | ) |

virtual

Your class does not have to derive from NetworkIDObject, although that is the easiest way to implement this. If you want this to be a member object of another class, rather than inherit, then call SetParent() with a pointer to the parent class instance. GET_OBJECT_FROM_ID will then return the parent rather than this instance.

Definition at line 89 of file NetworkIDObject.cpp.

References parent.

## Member Data Documentation

NetworkID SLNet::NetworkIDObject::networkID

protected

The network ID of this object.

Definition at line 81 of file NetworkIDObject.h.

Referenced by GetNetworkID(), NetworkIDObject(), SetNetworkID(), and SetNetworkIDManager().

NetworkIDManager* SLNet::NetworkIDObject::networkIDManager

protected

Definition at line 82 of file NetworkIDObject.h.

Referenced by GetNetworkIDManager(), NetworkIDObject(), SetNetworkID(), SetNetworkIDManager(), and ~NetworkIDObject().

NetworkIDObject* SLNet::NetworkIDObject::nextInstanceForNetworkIDManager

protected

Definition at line 89 of file NetworkIDObject.h.

Referenced by SLNet::NetworkIDManager::GET_BASE_OBJECT_FROM_ID(), NetworkIDObject(), SLNet::NetworkIDManager::StopTrackingNetworkIDObject(), and SLNet::NetworkIDManager::TrackNetworkIDObject().

void* SLNet::NetworkIDObject::parent

protected

The parent set by SetParent()

Definition at line 85 of file NetworkIDObject.h.

Referenced by GetParent(), NetworkIDObject(), and SetParent().

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

- Source/include/slikenet/NetworkIDObject.h
- Source/src/NetworkIDObject.cpp