# PluginInterface2 Class Reference
[PluginInterface2]

PluginInterface2 provides a mechanism to add functionality in a modular way. MessageHandlers should derive from PluginInterface and be attached to RakPeer using the function AttachPlugin On a user call to Receive, OnReceive is called for every PluginInterface, which can then take action based on the message passed to it. This is used to transparently add game-independent functional modules, similar to browser plugins. More...

`#include <PluginInterface2.h>`

Inheritance diagram for PluginInterface2:

List of all members.

## Public Member Functions
virtual void | OnAttach (void)
virtual void | OnDetach (void)
virtual void | Update (void)
| Update is called every time a packet is checked for .
virtual PluginReceiveResult | OnReceive (Packet *packet)
virtual void | OnStartup (void)
| Called when RakPeer is initialized.
virtual void | OnShutdown (void)
| Called when RakPeer is shutdown.
virtual void | OnClosedConnection (SystemAddress systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason)
virtual void | OnNewConnection (SystemAddress systemAddress, RakNetGUID rakNetGUID, bool isIncoming)
virtual void | OnFailedConnectionAttempt (SystemAddress systemAddress, PI2_FailedConnectionAttemptReason failedConnectionAttemptReason)
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 | OnInternalPacket (InternalPacket *internalPacket, unsigned frameNumber, SystemAddress remoteSystemAddress, RakNetTime time, bool isSend)
virtual void | OnAck (unsigned int messageNumber, SystemAddress remoteSystemAddress, RakNetTime time)
virtual void | OnPushBackPacket (const char *data, const BitSize_t bitsUsed, SystemAddress remoteSystemAddress)

## Detailed Description

PluginInterface2 provides a mechanism to add functionality in a modular way. MessageHandlers should derive from PluginInterface and be attached to RakPeer using the function AttachPlugin On a user call to Receive, OnReceive is called for every PluginInterface, which can then take action based on the message passed to it. This is used to transparently add game-independent functional modules, similar to browser plugins.

## Member Function Documentation

virtual void PluginInterface2::OnAck | ( | unsigned int | messageNumber,
|  | SystemAddress | remoteSystemAddress,
|  | RakNetTime | time |
| ) |  |  | `[inline, virtual]`

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

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 RakNet::GetTime()

Reimplemented in PacketLogger.

virtual void PluginInterface2::OnAttach | ( | void |  | ) | `[inline, virtual]`

Called when the interface is attached

Parameters:

  `[in]` | peer | the instance of RakPeer that is calling Receive

Reimplemented in RakNet::AutoRPC, FullyConnectedMesh2, NatPunchthroughClient, RakNet::ReplicaManager2, Router, and RakNet::RPC3.

virtual void PluginInterface2::OnClosedConnection | ( | SystemAddress | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | PI2_LostConnectionReason | lostConnectionReason |
| ) |  |  | `[inline, 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 in RakNet::AutoRPC, ConnectionGraph, ConnectionGraph2, FileListTransfer, FullyConnectedMesh2, LightweightDatabaseServer, MessageFilter, NatPunchthroughClient, NatPunchthroughServer, RakNetTransport2, ReadyEvent, ReplicaManager, RakNet::ReplicaManager2, RakNet::ReplicaManager3, RakNet::UDPProxyCoordinator, RakNet::UDPProxyServer, RakNet::Lobby2Client, RakNet::Lobby2Server, RakNet::RoomsPlugin, and RakNet::RPC3.

virtual void PluginInterface2::OnDetach | ( | void |  | ) | `[inline, virtual]`

Called when the interface is detached

Parameters:

  `[in]` | peer | the instance of RakPeer that is calling Receive

Reimplemented in NatPunchthroughClient, Router, and RakNet::RoomsPlugin.

virtual void PluginInterface2::OnDirectSocketReceive | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress |
| ) |  |  | `[inline, virtual]`

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

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 PacketLogger.

virtual void PluginInterface2::OnDirectSocketSend | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress |
| ) |  |  | `[inline, virtual]`

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

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 PacketLogger.

virtual void PluginInterface2::OnFailedConnectionAttempt | ( | SystemAddress | systemAddress,
|  | PI2_FailedConnectionAttemptReason | failedConnectionAttemptReason |
| ) |  |  | `[inline, virtual]`

Called when a connection attempt fails

Parameters:

  `[in]` | systemAddress | Address of the connection
  `[in]` | failedConnectionReason | Why the connection failed

virtual void PluginInterface2::OnInternalPacket | ( | InternalPacket * | internalPacket,
|  | unsigned | frameNumber,
|  | SystemAddress | remoteSystemAddress,
|  | RakNetTime | time,
|  | bool | isSend |
| ) |  |  | `[inline, virtual]`

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

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 RakNet::GetTime()
  `[in]` | isSend | Is this callback representing a send event or receive event?

Reimplemented in PacketLogger.

virtual void PluginInterface2::OnNewConnection | ( | SystemAddress | systemAddress,
|  | RakNetGUID | rakNetGUID,
|  | bool | isIncoming |
| ) |  |  | `[inline, 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 in ConnectionGraph, ConnectionGraph2, FullyConnectedMesh2, MessageFilter, NatPunchthroughClient, NatPunchthroughServer, RakNetTransport2, ReplicaManager, RakNet::ReplicaManager2, and RakNet::ReplicaManager3.

virtual void PluginInterface2::OnPushBackPacket | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress |
| ) |  |  | `[inline, virtual]`

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 PacketLogger.

virtual PluginReceiveResult PluginInterface2::OnReceive | ( | Packet * | packet | ) | `[inline, 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 in RakNet::AutoRPC, ConnectionGraph, DirectoryDeltaTransfer, FileListTransfer, FullyConnectedMesh, FullyConnectedMesh2, LightweightDatabaseServer, MessageFilter, NatPunchthroughClient, NatPunchthroughServer, RakNetTransport2, ReadyEvent, ReplicaManager, RakNet::ReplicaManager2, RakNet::ReplicaManager3, Router, RakNet::UDPProxyClient, RakNet::UDPProxyCoordinator, RakNet::UDPProxyServer, RakNet::Lobby2Client, RakNet::Lobby2Server, RakNet::RoomsPlugin, and RakNet::RPC3.

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

- C:/RakNet/Source/PluginInterface2.h
- C:/RakNet/Source/PluginInterface2.cpp