# PluginInterface Class Reference
[PluginInterface]

PluginInterface 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 <PluginInterface.h>`

Inheritance diagram for PluginInterface:

List of all members.

## Public Member Functions
virtual void | OnAttach (RakPeerInterface *peer)
virtual void | OnDetach (RakPeerInterface *peer)
virtual void | OnStartup (RakPeerInterface *peer)
virtual void | Update (RakPeerInterface *peer)
virtual PluginReceiveResult | OnReceive (RakPeerInterface *peer, Packet *packet)
virtual void | OnShutdown (RakPeerInterface *peer)
virtual void | OnCloseConnection (RakPeerInterface *peer, SystemAddress systemAddress)
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)

## Detailed Description

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

See also:
  ReplicaManager

  FullyConnectedMesh

  PacketLogger

## Member Function Documentation

void PluginInterface::OnAttach | ( | RakPeerInterface * | peer | ) | `[virtual]`

Called when the interface is attached

Parameters:

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

Reimplemented in RakNet::AutoRPC, DirectoryDeltaTransfer, FCMHost, FileListTransfer, LightweightDatabaseClient, LightweightDatabaseServer, MessageFilter, NatPunchthrough, PacketLogger, ReadyEvent, ReplicaManager, RakNet::ReplicaManager2, Router, RakNet::LobbyClientPC, RakNet::LobbyServer, RakNet::Lobby2Plugin, RakNet::RoomsPlugin, and RakNet::RPC3.

void PluginInterface::OnCloseConnection | ( | RakPeerInterface * | peer,
|  | SystemAddress | systemAddress |
| ) |  |  | `[virtual]`

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

Parameters:

  `[in]` | peer | the instance of RakPeer that is calling Receive
  `[in]` | systemAddress | The system whose connection was closed

Reimplemented in RakNet::AutoRPC, ConnectionGraph, FCMHost, FileListTransfer, LightweightDatabaseServer, MessageFilter, NatPunchthrough, ReadyEvent, ReplicaManager, RakNet::ReplicaManager2, Router, RakNet::LobbyClientPC, RakNet::LobbyServer, RakNet::Lobby2Client, RakNet::Lobby2Server, RakNet::RoomsPlugin, and RakNet::RPC3.

void PluginInterface::OnDetach | ( | RakPeerInterface * | peer | ) | `[virtual]`

Called when the interface is detached

Parameters:

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

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

void PluginInterface::OnDirectSocketReceive | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress |
| ) |  |  | `[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.

void PluginInterface::OnDirectSocketSend | ( | const char * | data,
|  | const BitSize_t | bitsUsed,
|  | SystemAddress | remoteSystemAddress |
| ) |  |  | `[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.

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

Called on a send or recieve 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.

PluginReceiveResult PluginInterface::OnReceive | ( | RakPeerInterface * | peer,
|  | Packet * | packet |
| ) |  |  | `[virtual]`

OnReceive is called for every packet.

Parameters:

  `[in]` | peer | the instance of RakPeer that is calling Receive
  `[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, FCMHost, FileListTransfer, FullyConnectedMesh, LightweightDatabaseClient, LightweightDatabaseServer, MessageFilter, NatPunchthrough, ReadyEvent, ReplicaManager, RakNet::ReplicaManager2, Router, RakNet::LobbyClientPC, RakNet::LobbyServer, RakNet::Lobby2Client, RakNet::Lobby2Server, RakNet::RoomsPlugin, and RakNet::RPC3.

void PluginInterface::OnShutdown | ( | RakPeerInterface * | peer | ) | `[virtual]`

Called when RakPeer is shutdown

Parameters:

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

Reimplemented in RakNet::AutoRPC, ConnectionGraph, DirectoryDeltaTransfer, FCMHost, FileListTransfer, FullyConnectedMesh, LightweightDatabaseServer, MessageFilter, NatPunchthrough, ReadyEvent, ReplicaManager, RakNet::ReplicaManager2, Router, RakNet::LobbyClientPC, RakNet::LobbyServer, RakNet::Lobby2Client, RakNet::Lobby2Server, RakNet::RoomsPlugin, and RakNet::RPC3.

void PluginInterface::OnStartup | ( | RakPeerInterface * | peer | ) | `[virtual]`

Called when RakPeer is initialized

Parameters:

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

void PluginInterface::Update | ( | RakPeerInterface * | peer | ) | `[virtual]`

Update is called every time a packet is checked for .

Parameters:

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

Reimplemented in ConnectionGraph, DirectoryDeltaTransfer, FileListTransfer, FullyConnectedMesh, LightweightDatabaseServer, MessageFilter, NatPunchthrough, PacketLogger, ReplicaManager, RakNet::ReplicaManager2, Router, ThreadsafePacketLogger, RakNet::LobbyServer, RakNet::LobbyServerPostgreSQL, RakNet::Lobby2Server, and RakNet::RoomsPlugin.

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

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