RakNet::TeamManager Class Reference
[TeamManager]

Automates networking and list management for teams. More...

#include <TeamManager.h>

Inheritance diagram for RakNet::TeamManager:

RakNet::PluginInterface2

List of all members.

Public Member Functions

TM_WorldAddWorld (WorldId worldId)
 Allocate a world to hold a list of teams and players for that team. Use the returned TM_World object for actual team functionality.
void RemoveWorld (WorldId worldId)
 Deallocate a world created with AddWorld().
unsigned int GetWorldCount (void) const
TM_WorldGetWorldAtIndex (unsigned int index) const
TM_WorldGetWorldWithId (WorldId worldId) const
void SetAutoManageConnections (bool autoAdd)
 When auto managing connections, call TM_World::AddParticipant() on all worlds for all new connections automatically Defaults to true.
void SetTopology (TMTopology _topology)
 If _topology is set to TM_CLIENT_SERVER, the host will relay messages to participants.
void DecomposeTeamFull (Packet *packet, TM_World **world, TM_TeamMember **teamMember, TM_Team **team, uint16_t &currentMembers, uint16_t &memberLimitIncludingBalancing, bool &balancingIsActive, JoinPermissions &joinPermissions)
 When you get ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, pass the packet to this function to read out parameters.
void DecomposeTeamLocked (Packet *packet, TM_World **world, TM_TeamMember **teamMember, TM_Team **team, uint16_t &currentMembers, uint16_t &memberLimitIncludingBalancing, bool &balancingIsActive, JoinPermissions &joinPermissions)
 When you get ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED, pass the packet to this function to read out parameters.
void Clear (void)
 Clear all memory and reset everything.
void DecodeTeamAssigned (Packet *packet, TM_World **world, TM_TeamMember **teamMember)
 Reads out the world and teamMember from ID_TEAM_BALANCER_TEAM_ASSIGNED.
void DecodeTeamCancelled (Packet *packet, TM_World **world, TM_TeamMember **teamMember, TM_Team **teamCancelled)

Protected Member Functions

virtual void Update (void)
 Update is called every time a packet is checked for .
virtual PluginReceiveResult OnReceive (Packet *packet)
virtual void OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
void DecodeTeamAssigned (RakNet::BitStream *bsIn, TM_World **world, TM_TeamMember **teamMember, NoTeamId &noTeamSubcategory, JoinTeamType &joinTeamType, DataStructures::List< TM_Team * > &newTeam, DataStructures::List< TM_Team * > &teamsLeft, DataStructures::List< TM_Team * > &teamsJoined)
 When you get ID_TEAM_BALANCER_TEAM_ASSIGNED, pass the packet to this function to read out parameters.


Detailed Description

Automates networking and list management for teams.

TeamManager provides support for teams. A team is a list of team members. Teams contain properties including the number of team members per team, whether or not tagged teams must have equal numbers of members, and if a team is locked or not to certain entry conditions Team members contain properties including which teams they are on and which teams they want to join if a team is not immediately joinable Advanced functionality includes the ability for a team member to be on multiple teams simultaneously, the ability to swap teams with other members, and the ability to resize the number of members supported per team The architecture is designed for easy integration with ReplicaManager3

Usage:
1. Define your game classes to represent teams and team members. Your game classes should hold game-specific information such as team name and color.
2. Have those game classes contain a corresponding TM_Team or TM_TeamMember instance. Operations on teams will be performed by those instances. Use SetOwner() to refer to the parent object when using composition.
3. Call TeamManager::SetTopology() for client/server or peer to peer.
4. Call AddWorld() to instantiate a TM_World object which will contain references to your TM_TeamMember and TM_Team instances.
5. When you instantiate a TM_TeamMember or TM_Team object, call ReferenceTeam() and ReferenceTeamMember() for each corresponding object
6. When sending world state to a new connection, for example in ReplicaManager3::SerializeConstruction(), call TM_SerializeConstruction() on the corresponding TM_TeamMember and TM_Team objects. TM_Team instances on the new connection must be created before TM_TeamMember instances.
7. Call TM_DeserializeConstruction() on your new corresponding TM_TeamMember and TM_Team instances.
8. Execute team operations. ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED, ID_TEAM_BALANCER_TEAM_REQUESTED_CANCELLED, and ID_TEAM_BALANCER_TEAM_ASSIGNED are returned to all systems when the corresponding event occurs for a team member.
9. As the peer to peer session host changes, call SetHost() (Not necessary if using FullyConnectedMesh2). If using client/server, you must set the host

Note:
This replaces TeamBalancer. You cannot use TeamBalancer and TeamManager at the same time.

Member Function Documentation

TM_World* RakNet::TeamManager::AddWorld ( WorldId  worldId  ) 

Allocate a world to hold a list of teams and players for that team. Use the returned TM_World object for actual team functionality.

Note:
The world is tracked by TeamManager and deallocated by calling Clear()
Parameters:
[in] worldId Arbitrary user-defined id of the world to create. Each world instance must have a unique id.

void RakNet::TeamManager::Clear ( void   ) 

Clear all memory and reset everything.

Deallocates TM_World instances. It is up to the user to deallocate pointers passed to ReferenceTeamMember() or ReferenceTeam(), if so desired.

void RakNet::TeamManager::DecodeTeamAssigned ( RakNet::BitStream bsIn,
TM_World **  world,
TM_TeamMember **  teamMember,
NoTeamId noTeamSubcategory,
JoinTeamType joinTeamType,
DataStructures::List< TM_Team * > &  newTeam,
DataStructures::List< TM_Team * > &  teamsLeft,
DataStructures::List< TM_Team * > &  teamsJoined 
) [protected]

When you get ID_TEAM_BALANCER_TEAM_ASSIGNED, pass the packet to this function to read out parameters.

Parameters:
[in] A packet where packet->data[0]==ID_TEAM_BALANCER_TEAM_ASSIGNED
Returns:
true on success, false on read error

void RakNet::TeamManager::DecodeTeamAssigned ( Packet packet,
TM_World **  world,
TM_TeamMember **  teamMember 
)

Reads out the world and teamMember from ID_TEAM_BALANCER_TEAM_ASSIGNED.

Note:
You can get the current and prior team list from the teamMember itself
Parameters:
[in] A packet where packet->data[0]==ID_TEAM_BALANCER_TEAM_ASSIGNED
[out] world Set to the world this teamMember is on. 0 on bad lookup.
[out] teamMember Set to the teamMember affected. 0 on bad lookup.

void RakNet::TeamManager::DecodeTeamCancelled ( Packet packet,
TM_World **  world,
TM_TeamMember **  teamMember,
TM_Team **  teamCancelled 
)

Note:
You can get the requested team list from the teamMember itself
Parameters:
[in] A packet where packet->data[0]==ID_TEAM_BALANCER_TEAM_REQUESTED_CANCELLED
[out] world Set to the world this teamMember is on. 0 on bad lookup.
[out] teamMember Set to the teamMember affected. 0 on bad lookup.
[out] teamCancelled Set to the team that was cancelled. 0 for all teams.

void RakNet::TeamManager::DecomposeTeamFull ( Packet packet,
TM_World **  world,
TM_TeamMember **  teamMember,
TM_Team **  team,
uint16_t &  currentMembers,
uint16_t &  memberLimitIncludingBalancing,
bool &  balancingIsActive,
JoinPermissions &  joinPermissions 
)

When you get ID_TEAM_BALANCER_REQUESTED_TEAM_FULL, pass the packet to this function to read out parameters.

Parameters:
[in] A packet where packet->data[0]==ID_TEAM_BALANCER_REQUESTED_TEAM_FULL
Returns:
true on success, false on read error

void RakNet::TeamManager::DecomposeTeamLocked ( Packet packet,
TM_World **  world,
TM_TeamMember **  teamMember,
TM_Team **  team,
uint16_t &  currentMembers,
uint16_t &  memberLimitIncludingBalancing,
bool &  balancingIsActive,
JoinPermissions &  joinPermissions 
)

When you get ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED, pass the packet to this function to read out parameters.

Parameters:
[in] A packet where packet->data[0]==ID_TEAM_BALANCER_REQUESTED_TEAM_LOCKED
Returns:
true on success, false on read error

TM_World* RakNet::TeamManager::GetWorldAtIndex ( unsigned int  index  )  const

Parameters:
[in] index A value beteween 0 and GetWorldCount()-1 inclusive.
Returns:
Returns a world created with AddWorld()

unsigned int RakNet::TeamManager::GetWorldCount ( void   )  const

Returns:
Returns the number of worlds created with AddWorld()

TM_World* RakNet::TeamManager::GetWorldWithId ( WorldId  worldId  )  const

Parameters:
[in] worldId worldId value passed to AddWorld()
Returns:
Returns a world created with AddWorld(), or 0 if no such worldId

virtual void RakNet::TeamManager::OnClosedConnection ( const SystemAddress systemAddress,
RakNetGUID  rakNetGUID,
PI2_LostConnectionReason  lostConnectionReason 
) [protected, virtual]

Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system

Parameters:
[in] systemAddress The system whose connection was closed
[in] rakNetGuid The guid of the specified system
[in] lostConnectionReason How the connection was closed: manually, connection lost, or notification of disconnection

Reimplemented from RakNet::PluginInterface2.

virtual void RakNet::TeamManager::OnNewConnection ( const SystemAddress systemAddress,
RakNetGUID  rakNetGUID,
bool  isIncoming 
) [protected, virtual]

Called when we got a new connection

Parameters:
[in] systemAddress Address of the new connection
[in] rakNetGuid The guid of the specified system
[in] isIncoming If true, this is ID_NEW_INCOMING_CONNECTION, or the equivalent

Reimplemented from RakNet::PluginInterface2.

virtual PluginReceiveResult RakNet::TeamManager::OnReceive ( Packet packet  )  [protected, virtual]

OnReceive is called for every packet.

Parameters:
[in] packet the packet that is being returned to the user
Returns:
True to allow the game and other plugins to get this message, false to absorb it

Reimplemented from RakNet::PluginInterface2.

void RakNet::TeamManager::RemoveWorld ( WorldId  worldId  ) 

Deallocate a world created with AddWorld().

Parameters:
[in] worldId The world to deallocate

void RakNet::TeamManager::SetAutoManageConnections ( bool  autoAdd  ) 

When auto managing connections, call TM_World::AddParticipant() on all worlds for all new connections automatically Defaults to true.

Note:
You probably want this set to false if using multiple worlds
Parameters:
[in] autoAdd Automatically call TM_World::AddParticipant() all worlds each new connection. Defaults to true.

void RakNet::TeamManager::SetTopology ( TMTopology  _topology  ) 

If _topology is set to TM_CLIENT_SERVER, the host will relay messages to participants.

If topology is set to TM_PEER_TO_PEER, the host assumes the original message source was connected to all other participants and does not relay messages.

Note:
If TM_PEER_TO_PEER, this plugin will listen for ID_FCM2_NEW_HOST and call SetHost() on all worlds automatically

Defaults to TM_PEER_TO_PEER

Parameters:
[in] _topology Topology to use


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

Generated on Wed Apr 4 21:34:41 2012 for RakNet by  doxygen 1.5.7.1