SLikeNet 0.1.3

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Modules | Classes | Enumerations
PluginInterface2

## Modules

| Plugins

## Classes

class | SLNet::PluginInterface2

## Enumerations

enum | SLNet::PluginReceiveResult { SLNet::RR_STOP_PROCESSING_AND_DEALLOCATE =0, SLNet::RR_CONTINUE_PROCESSING, SLNet::RR_STOP_PROCESSING }
enum | SLNet::PI2_LostConnectionReason { SLNet::LCR_CLOSED_BY_USER, SLNet::LCR_DISCONNECTION_NOTIFICATION, SLNet::LCR_CONNECTION_LOST }

enum

SLNet::PI2_FailedConnectionAttemptReason {
SLNet::FCAR_CONNECTION_ATTEMPT_FAILED, SLNet::FCAR_ALREADY_CONNECTED, SLNet::FCAR_NO_FREE_INCOMING_CONNECTIONS, SLNet::FCAR_SECURITY_PUBLIC_KEY_MISMATCH,
SLNet::FCAR_CONNECTION_BANNED, SLNet::FCAR_INVALID_PASSWORD, SLNet::FCAR_INCOMPATIBLE_PROTOCOL, SLNet::FCAR_IP_RECENTLY_CONNECTED,
SLNet::FCAR_REMOTE_SYSTEM_REQUIRES_PUBLIC_KEY, SLNet::FCAR_OUR_SYSTEM_REQUIRES_SECURITY, SLNet::FCAR_PUBLIC_KEY_MISMATCH
}

## Detailed Description

## Class Documentation

class SLNet::PluginInterface2

RakNet's plugin system. Each plugin processes the following events: -Connection attempts -The result of connection attempts -Each incoming message -Updates over time, when RakPeer::Receive() is called

Definition at line 94 of file PluginInterface2.h.

Inheritance diagram for SLNet::PluginInterface2:

### Public Member Functions

| PluginInterface2 ()
virtual | ~PluginInterface2 ()
virtual void | OnAttach (void)
| Called when the interface is attached.
virtual void | OnDetach (void)
| Called when the interface is detached.
virtual void | Update (void)
| Update is called every time a packet is checked for .
virtual PluginReceiveResult | OnReceive (Packet *packet)
virtual void | OnRakPeerStartup (void)
| Called when RakPeer is initialized.
virtual void | OnRakPeerShutdown (void)
| Called when RakPeer is shutdown.
virtual void | OnClosedConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void | OnNewConnection (const SystemAddress &systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
virtual void | OnFailedConnectionAttempt (Packet *packet, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason)
virtual bool | UsesReliabilityLayer (void) const
virtual void | OnDirectSocketSend (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnDirectSocketReceive (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
virtual void | OnReliabilityLayerNotification (const char *errorMessage, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress, bool isError)
virtual void | OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time, int isSend)
virtual void | OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, SLNet::TimeMS time)
virtual void | OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)
RakPeerInterface * | GetRakPeerInterface (void) const
RakNetGUID | GetMyGUIDUnified (void) const
void | SetRakPeerInterface (RakPeerInterface *ptr)
void | SetTCPInterface (TCPInterface *ptr)

### Protected Member Functions

void | SendUnified (const SLNet::BitStream *bitStream, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
void | SendUnified (const char *data, const int length, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
bool | SendListUnified (const char **data, const int *lengths, const int numParameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, const AddressOrGUID systemIdentifier, bool broadcast)
Packet * | AllocatePacketUnified (unsigned dataSize)
void | PushBackPacketUnified (Packet *packet, bool pushAtHead)
void | DeallocPacketUnified (Packet *packet)

### Protected Attributes

RakPeerInterface * | rakPeerInterface
TCPInterface * | tcpInterface

#### Constructor & Destructor Documentation

PluginInterface2::PluginInterface2 | ( |  | ) |

Definition at line 24 of file PluginInterface2.cpp.

References rakPeerInterface, and tcpInterface.

PluginInterface2::~PluginInterface2 | ( |  | ) |

virtual

Definition at line 31 of file PluginInterface2.cpp.

#### Member Function Documentation

Packet * PluginInterface2::AllocatePacketUnified | ( | unsigned | dataSize | ) |

protected

Definition at line 103 of file PluginInterface2.cpp.

References _FILE_AND_LINE_, SLNet::TCPInterface::AllocatePacket(), SLNet::RakPeerInterface::AllocatePacket(), SLNet::Packet::bitSize, BYTES_TO_BITS, SLNet::Packet::data, SLNet::Packet::deleteData, SLNet::Packet::guid, rakMalloc_Ex, rakPeerInterface, SLNet::Packet::systemAddress, tcpInterface, SLNet::UNASSIGNED_RAKNET_GUID(), SLNet::UNASSIGNED_SYSTEM_ADDRESS, and SLNet::Packet::wasGeneratedLocally.

void PluginInterface2::DeallocPacketUnified | ( | Packet * | packet | ) |

protected

Definition at line 143 of file PluginInterface2.cpp.

References _FILE_AND_LINE_, SLNet::Packet::data, SLNet::TCPInterface::DeallocatePacket(), SLNet::RakPeerInterface::DeallocatePacket(), SLNet::OP_DELETE(), rakFree_Ex, rakPeerInterface, and tcpInterface.

RakNetGUID PluginInterface2::GetMyGUIDUnified | ( | void |  | ) | const

Definition at line 221 of file PluginInterface2.cpp.

References SLNet::RakPeerInterface::GetMyGUID(), rakPeerInterface, and SLNet::UNASSIGNED_RAKNET_GUID().

Referenced by SendListUnified(), and SendUnified().

RakPeerInterface* SLNet::PluginInterface2::GetRakPeerInterface | ( | void |  | ) | const

inline

Definition at line 184 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnAck | ( | unsigned int | messageNumber,
|  | SystemAddress | remoteSystemAddress,
|  | SLNet::TimeMS | time
| ) |  |

inlinevirtual

Called when we get an ack for a message we reliably sent

Precondition
  To be called, UsesReliabilityLayer() must return true

Parameters

  [in] | messageNumber | The numerical identifier for which message this is
  [in] | remoteSystemAddress | The player we sent or got this packet from
  [in] | time | The current time as returned by SLNet::GetTimeMS()

Reimplemented in SLNet::PacketLogger.

Definition at line 176 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnAttach | ( | void |  | ) |

inlinevirtual

Called when the interface is attached.

Reimplemented in SLNet::RPC4, SLNet::NatPunchthroughClient, SLNet::TeamBalancer, and SLNet::UDPProxyServer.

Definition at line 101 of file PluginInterface2.h.

Referenced by SLNet::RakPeer::AttachPlugin().

virtual void SLNet::PluginInterface2::OnClosedConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | PI2_LostConnectionReason | lostConnectionReason
| ) |  |

inlinevirtual

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 in SLNet::TeamManager, SLNet::ReplicaManager3, SLNet::StatisticsHistoryPlugin, SLNet::ReadyEvent, SLNet::NatPunchthroughClient, SLNet::MessageFilter, SLNet::TeamBalancer, SLNet::CloudServer, SLNet::FileListTransfer, SLNet::RelayPlugin, SLNet::ConnectionGraph2, SLNet::UDPProxyServer, SLNet::Router2, SLNet::NatPunchthroughServer, SLNet::HTTPConnection2, SLNet::RakNetTransport2, SLNet::TwoWayAuthentication, SLNet::NatTypeDetectionServer, SLNet::NatTypeDetectionClient, and SLNet::UDPProxyCoordinator.

Definition at line 124 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnDetach | ( | void |  | ) |

inlinevirtual

Called when the interface is detached.

Reimplemented in SLNet::ReplicaManager3, SLNet::NatPunchthroughClient, SLNet::UDPProxyServer, and SLNet::NatTypeDetectionClient.

Definition at line 104 of file PluginInterface2.h.

Referenced by SLNet::RakPeer::DetachPlugin().

virtual void SLNet::PluginInterface2::OnDirectSocketReceive | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress
| ) |  |

inlinevirtual

Called on a receive from the socket, per datagram, that does not go through the reliability layer

Precondition
  To be called, UsesReliabilityLayer() must return true

Parameters

  [in] | data | The data being sent
  [in] | bitsUsed | How many bits long data is
  [in] | remoteSystemAddress | Which system this message is being sent to

Reimplemented in SLNet::PacketLogger.

Definition at line 154 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnDirectSocketSend | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress
| ) |  |

inlinevirtual

Called on a send to the socket, per datagram, that does not go through the reliability layer

Precondition
  To be called, UsesReliabilityLayer() must return true

Parameters

  [in] | data | The data being sent
  [in] | bitsUsed | How many bits long data is
  [in] | remoteSystemAddress | Which system this message is being sent to

Reimplemented in SLNet::PacketLogger.

Definition at line 147 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnFailedConnectionAttempt | ( | Packet * | packet,
|  | PI2_FailedConnectionAttemptReason | failedConnectionAttemptReason
| ) |  |

inlinevirtual

Called when a connection attempt fails

Parameters

  [in] | packet | Packet to be returned to the user
  [in] | failedConnectionReason | Why the connection failed

Reimplemented in SLNet::Router2, and SLNet::HTTPConnection2.

Definition at line 135 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnInternalPacket | ( | InternalPacket * | internalPacket,
|  | unsigned | frameNumber,
|  | SystemAddress | remoteSystemAddress,
|  | SLNet::TimeMS | time,
|  | int | isSend
| ) |  |

inlinevirtual

Called on a send or receive of a message within the reliability layer

Precondition
  To be called, UsesReliabilityLayer() must return true

Parameters

  [in] | internalPacket | The user message, along with all send data.
  [in] | frameNumber | The number of frames sent or received so far for this player depending on isSend . Indicates the frame of this user message.
  [in] | remoteSystemAddress | The player we sent or got this packet from
  [in] | time | The current time as returned by SLNet::GetTimeMS()
  [in] | isSend | Is this callback representing a send event or receive event?

Reimplemented in SLNet::PacketLogger.

Definition at line 169 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnNewConnection | ( | const SystemAddress & | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | bool | isIncoming
| ) |  |

inlinevirtual

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 in SLNet::TeamManager, SLNet::ReplicaManager3, SLNet::StatisticsHistoryPlugin, SLNet::NatPunchthroughClient, SLNet::MessageFilter, SLNet::ConnectionGraph2, SLNet::NatPunchthroughServer, SLNet::HTTPConnection2, and SLNet::RakNetTransport2.

Definition at line 130 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnPushBackPacket | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress
| ) |  |

inlinevirtual

System called RakPeerInterface::PushBackPacket

Parameters

  [in] | data | The data being sent
  [in] | bitsUsed | How many bits long data is
  [in] | remoteSystemAddress | The player we sent or got this packet from

Reimplemented in SLNet::PacketLogger.

Definition at line 182 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnRakPeerShutdown | ( | void |  | ) |

inlinevirtual

Called when RakPeer is shutdown.

Reimplemented in SLNet::ReplicaManager3, SLNet::ReadyEvent, SLNet::NatPunchthroughClient, SLNet::UDPProxyClient, SLNet::CloudServer, SLNet::FileListTransfer, SLNet::UDPProxyServer, SLNet::Router2, SLNet::TwoWayAuthentication, and SLNet::NatTypeDetectionClient.

Definition at line 118 of file PluginInterface2.h.

virtual void SLNet::PluginInterface2::OnRakPeerStartup | ( | void |  | ) |

inlinevirtual

Called when RakPeer is initialized.

Reimplemented in SLNet::UDPProxyServer.

Definition at line 115 of file PluginInterface2.h.

virtual PluginReceiveResult SLNet::PluginInterface2::OnReceive | ( | Packet * | packet | ) |

inlinevirtual

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 in SLNet::TeamManager, SLNet::ReplicaManager3, SLNet::RPC4, SLNet::ReadyEvent, SLNet::NatPunchthroughClient, SLNet::MessageFilter, SLNet::DirectoryDeltaTransfer, SLNet::TeamBalancer, SLNet::UDPProxyClient, SLNet::CloudClient, SLNet::CloudServer, SLNet::FileListTransfer, SLNet::ConnectionGraph2, SLNet::RelayPlugin, SLNet::UDPProxyServer, SLNet::Router2, SLNet::HTTPConnection2, SLNet::NatPunchthroughServer, SLNet::RakNetTransport2, SLNet::TwoWayAuthentication, SLNet::NatTypeDetectionServer, SLNet::NatTypeDetectionClient, and SLNet::UDPProxyCoordinator.

Definition at line 112 of file PluginInterface2.h.

References SLNet::RR_CONTINUE_PROCESSING.

Referenced by PushBackPacketUnified(), and SendUnified().

virtual void SLNet::PluginInterface2::OnReliabilityLayerNotification | ( | const char * | errorMessage,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress,
|  | bool | isError
| ) |  |

inlinevirtual

Called when the reliability layer rejects a send or receive

Precondition
  To be called, UsesReliabilityLayer() must return true

Parameters

  [in] | bitsUsed | How many bits long data is
  [in] | remoteSystemAddress | Which system this message is being sent to

Reimplemented in SLNet::PacketLogger.

Definition at line 160 of file PluginInterface2.h.

void PluginInterface2::PushBackPacketUnified | ( | Packet * | packet,
|  | bool | pushAtHead
| ) |  |

protected

Definition at line 125 of file PluginInterface2.cpp.

References OnReceive(), SLNet::TCPInterface::PushBackPacket(), SLNet::RakPeerInterface::PushBackPacket(), rakPeerInterface, tcpInterface, and Update().

bool PluginInterface2::SendListUnified | ( | const char ** | data,
|  | const int * | lengths,
|  | const int | numParameters,
|  | PacketPriority | priority,
|  | PacketReliability | reliability,
|  | char | orderingChannel,
|  | const AddressOrGUID | systemIdentifier,
|  | bool | broadcast
| ) |  |

protected

Definition at line 161 of file PluginInterface2.cpp.

References _FILE_AND_LINE_, GetMyGUIDUnified(), notifyOutOfMemory, rakFree_Ex, rakMalloc_Ex, SLNet::AddressOrGUID::rakNetGuid, rakPeerInterface, SLNet::TCPInterface::SendList(), SLNet::RakPeerInterface::SendList(), SendUnified(), SLNet::AddressOrGUID::systemAddress, and tcpInterface.

void PluginInterface2::SendUnified | ( | const SLNet::BitStream * | bitStream,
|  | PacketPriority | priority,
|  | PacketReliability | reliability,
|  | char | orderingChannel,
|  | const AddressOrGUID | systemIdentifier,
|  | bool | broadcast
| ) |  |

protected

Definition at line 35 of file PluginInterface2.cpp.

References SLNet::Packet::bitSize, SLNet::Packet::data, SLNet::Packet::deleteData, SLNet::BitStream::GetData(), GetMyGUIDUnified(), SLNet::BitStream::GetNumberOfBitsUsed(), SLNet::BitStream::GetNumberOfBytesUsed(), SLNet::Packet::guid, SLNet::Packet::length, OnReceive(), SLNet::AddressOrGUID::rakNetGuid, rakPeerInterface, SLNet::TCPInterface::Send(), SLNet::RakPeerInterface::Send(), SLNet::AddressOrGUID::systemAddress, SLNet::Packet::systemAddress, tcpInterface, SLNet::UNASSIGNED_RAKNET_GUID(), SLNet::UNASSIGNED_SYSTEM_ADDRESS, Update(), and SLNet::Packet::wasGeneratedLocally.

Referenced by SendListUnified().

void PluginInterface2::SendUnified | ( | const char * | data,
|  | const int | length,
|  | PacketPriority | priority,
|  | PacketReliability | reliability,
|  | char | orderingChannel,
|  | const AddressOrGUID | systemIdentifier,
|  | bool | broadcast
| ) |  |

protected

Definition at line 69 of file PluginInterface2.cpp.

References SLNet::Packet::bitSize, BYTES_TO_BITS, SLNet::Packet::data, SLNet::Packet::deleteData, GetMyGUIDUnified(), SLNet::Packet::guid, SLNet::Packet::length, OnReceive(), SLNet::AddressOrGUID::rakNetGuid, rakPeerInterface, SLNet::TCPInterface::Send(), SLNet::RakPeerInterface::Send(), SLNet::AddressOrGUID::systemAddress, SLNet::Packet::systemAddress, tcpInterface, SLNet::UNASSIGNED_RAKNET_GUID(), SLNet::UNASSIGNED_SYSTEM_ADDRESS, Update(), and SLNet::Packet::wasGeneratedLocally.

void PluginInterface2::SetRakPeerInterface | ( | RakPeerInterface * | ptr | ) |

Definition at line 211 of file PluginInterface2.cpp.

References rakPeerInterface.

Referenced by SLNet::RakPeer::AttachPlugin(), and SLNet::RakPeer::DetachPlugin().

void SLNet::PluginInterface2::SetTCPInterface | ( | TCPInterface * | ptr | ) |

virtual void SLNet::PluginInterface2::Update | ( | void |  | ) |

inlinevirtual

Update is called every time a packet is checked for .

Reimplemented in SLNet::TeamManager, SLNet::ReplicaManager3, SLNet::StatisticsHistoryPlugin, SLNet::NatPunchthroughClient, SLNet::MessageFilter, SLNet::UDPProxyClient, SLNet::CloudServer, SLNet::FileListTransfer, SLNet::UDPProxyServer, SLNet::Router2, SLNet::NatPunchthroughServer, SLNet::TwoWayAuthentication, SLNet::NatTypeDetectionServer, SLNet::NatTypeDetectionClient, SLNet::UDPProxyCoordinator, and SLNet::ThreadsafePacketLogger.

Definition at line 107 of file PluginInterface2.h.

Referenced by PushBackPacketUnified(), and SendUnified().

virtual bool SLNet::PluginInterface2::UsesReliabilityLayer | ( | void |  | ) | const

inlinevirtual

Queried when attached to RakPeer Return true to call OnDirectSocketSend(), OnDirectSocketReceive(), OnReliabilityLayerNotification(), OnInternalPacket(), and OnAck() If true, then you cannot call RakPeer::AttachPlugin() or RakPeer::DetachPlugin() for this plugin, while RakPeer is active

Reimplemented in SLNet::PacketLogger.

Definition at line 140 of file PluginInterface2.h.

Referenced by SLNet::RakPeer::AttachPlugin(), and SLNet::RakPeer::DetachPlugin().

#### Member Data Documentation

RakPeerInterface* SLNet::PluginInterface2::rakPeerInterface

protected

Definition at line 207 of file PluginInterface2.h.

Referenced by AllocatePacketUnified(), DeallocPacketUnified(), GetMyGUIDUnified(), PluginInterface2(), PushBackPacketUnified(), SendListUnified(), SendUnified(), and SetRakPeerInterface().

TCPInterface* SLNet::PluginInterface2::tcpInterface

protected

Definition at line 209 of file PluginInterface2.h.

Referenced by AllocatePacketUnified(), DeallocPacketUnified(), PluginInterface2(), PushBackPacketUnified(), SendListUnified(), and SendUnified().

## Enumeration Type Documentation

enum SLNet::PI2_FailedConnectionAttemptReason

Returns why a connection attempt failed

Enumerator:

  FCAR_CONNECTION_ATTEMPT_FAILED |
  FCAR_ALREADY_CONNECTED |
  FCAR_NO_FREE_INCOMING_CONNECTIONS |
  FCAR_SECURITY_PUBLIC_KEY_MISMATCH |
  FCAR_CONNECTION_BANNED |
  FCAR_INVALID_PASSWORD |
  FCAR_INCOMPATIBLE_PROTOCOL |
  FCAR_IP_RECENTLY_CONNECTED |
  FCAR_REMOTE_SYSTEM_REQUIRES_PUBLIC_KEY |
  FCAR_OUR_SYSTEM_REQUIRES_SECURITY |
  FCAR_PUBLIC_KEY_MISMATCH |

Definition at line 72 of file PluginInterface2.h.

enum SLNet::PI2_LostConnectionReason

Reasons why a connection was lost

Enumerator:

  LCR_CLOSED_BY_USER | Called RakPeer::CloseConnection()
  LCR_DISCONNECTION_NOTIFICATION | Got ID_DISCONNECTION_NOTIFICATION.
  LCR_CONNECTION_LOST | GOT ID_CONNECTION_LOST.

Definition at line 58 of file PluginInterface2.h.

enum SLNet::PluginReceiveResult

For each message that arrives on an instance of RakPeer, the plugins get an opportunity to process them first. This enumeration represents what to do with the message

Enumerator:

  RR_STOP_PROCESSING_AND_DEALLOCATE | The plugin used this message and it shouldn't be given to the user.
  RR_CONTINUE_PROCESSING | This message will be processed by other plugins, and at last by the user.
  RR_STOP_PROCESSING | The plugin is going to hold on to this message. Do not deallocate it but do not pass it to other plugins either.

Definition at line 44 of file PluginInterface2.h.