#include <ConnectionGraph.h>
Classes | |
struct | SystemAddressAndGroupId |
A node in the connection graph. More... | |
Public Member Functions | |
void | SetPassword (const char *password) |
Plaintext encoding of the password, or 0 for none. If you use a password, use secure connections. | |
DataStructures::WeightedGraph < ConnectionGraph::SystemAddressAndGroupId, unsigned short, false > * | GetGraph (void) |
Returns the connection graph. | |
void | SetAutoAddNewConnections (bool autoAdd) |
Automatically add new connections to the connection graph. | |
void | RequestConnectionGraph (SystemAddress systemAddress) |
Requests the connection graph from another system. | |
void | AddNewConnection (RakPeerInterface *peer, SystemAddress systemAddress, RakNetGUID guid, ConnectionGraphGroupID groupId) |
Adds a new connection to the connection graph from this system to the specified system. Also assigns a group identifier for that system. | |
void | SetGroupId (ConnectionGraphGroupID groupId) |
Sets our own group ID. | |
void | SubscribeToGroup (ConnectionGraphGroupID groupId) |
Allows adding to the connection graph nodes with this groupId. | |
void | UnsubscribeFromGroup (ConnectionGraphGroupID groupId) |
Disables addition of graph nodes with this groupId. | |
virtual void | OnRakPeerShutdown (void) |
Called when RakPeer is shutdown. | |
virtual void | Update (void) |
Update is called every time a packet is checked for . | |
virtual PluginReceiveResult | OnReceive (Packet *packet) |
virtual void | OnClosedConnection (SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason) |
virtual void | OnNewConnection (SystemAddress systemAddress, RakNetGUID rakNetGUID, bool isIncoming) |
void ConnectionGraph::AddNewConnection | ( | RakPeerInterface * | peer, | |
SystemAddress | systemAddress, | |||
RakNetGUID | guid, | |||
ConnectionGraphGroupID | groupId | |||
) |
Adds a new connection to the connection graph from this system to the specified system. Also assigns a group identifier for that system.
Only used and valid when SetAutoAddNewConnections(false) is called. Call this for this system sometime after getting ID_NEW_INCOMING_CONNECTION or ID_CONNECTION_REQUEST_ACCEPTED for systems that contain a connection graph Groups are sets of one or more nodes in the total graph We only add to the graph groups which we subscribe to
[in] | peer | The instance of RakPeer to send through |
[in] | systemAddress | The system that is connected to us. |
[in] | guid | The system that is connected to us. |
[in] | groupId | Just a number representing a group. Important: 0 is reserved to mean unassigned group ID and is assigned to all systems added with SetAutoAddNewConnections(true) |
DataStructures::WeightedGraph<ConnectionGraph::SystemAddressAndGroupId, unsigned short, false>* ConnectionGraph::GetGraph | ( | void | ) |
Returns the connection graph.
virtual void ConnectionGraph::OnClosedConnection | ( | SystemAddress | systemAddress, | |
RakNetGUID | rakNetGUID, | |||
PI2_LostConnectionReason | lostConnectionReason | |||
) | [virtual] |
Called when a connection is dropped because the user called RakPeer::CloseConnection() for a particular system
[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 PluginInterface2.
virtual void ConnectionGraph::OnNewConnection | ( | SystemAddress | systemAddress, | |
RakNetGUID | rakNetGUID, | |||
bool | isIncoming | |||
) | [virtual] |
Called when we got a new connection
[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 PluginInterface2.
virtual PluginReceiveResult ConnectionGraph::OnReceive | ( | Packet * | packet | ) | [virtual] |
OnReceive is called for every packet.
[in] | packet | the packet that is being returned to the user |
Reimplemented from PluginInterface2.
void ConnectionGraph::RequestConnectionGraph | ( | SystemAddress | systemAddress | ) |
Requests the connection graph from another system.
Only necessary to call if SetAutoAddNewConnections(false) is called. You should call this sometime after getting ID_CONNECTION_REQUEST_ACCEPTED and systemAddress is or should be a node on the connection graph
[in] | systemAddress | The system to send to |
void ConnectionGraph::SetAutoAddNewConnections | ( | bool | autoAdd | ) |
Automatically add new connections to the connection graph.
Defaults to true If true, then the system will automatically add all new connections for you, assigning groupId 0 to these systems. If you want more control, you should call SetAutoAddNewConnections(false); When false, it is up to you to call RequestConnectionGraph and AddNewConnection to complete the graph However, this way you can choose which nodes are on the graph for this system and can assign groupIds to those nodes
[in] | autoAdd | true to automatically add new connections to the connection graph. False to not do so. |
void ConnectionGraph::SetGroupId | ( | ConnectionGraphGroupID | groupId | ) |
Sets our own group ID.
Only used and valid when SetAutoAddNewConnections(false) is called. Defaults to 0
[in] | groupId | Our group ID |
void ConnectionGraph::SubscribeToGroup | ( | ConnectionGraphGroupID | groupId | ) |
Allows adding to the connection graph nodes with this groupId.
By default, you subscribe to group 0, which are all systems automatically added with SetAutoAddNewConnections(true) Calling this does not add nodes which were previously rejected due to an unsubscribed group - it only allows addition of nodes after the fact
[in] | groupId | Just a number representing a group. 0 is reserved to mean unassigned group ID, automatically added with SetAutoAddNewConnections(true) |
void ConnectionGraph::UnsubscribeFromGroup | ( | ConnectionGraphGroupID | groupId | ) |
Disables addition of graph nodes with this groupId.
Calling this does not add remove nodes with this groupId which are already present in the graph. It only disables addition of nodes after the fact
[in] | groupId | Just a number representing a group. 0 is reserved to mean unassigned group ID, automatically added with SetAutoAddNewConnections(true) |