Photon Server API
Public Member Functions | List of all members
Photon.SocketServer.Rpc.Reflection.OperationMethodInfoCache Class Reference

This cache enables high performance mapping of operation codes to operations. It collaborates with the OperationDispatcher. Instances of this class should be reused if possible since the method registration is slower than the mapping. Registered methods must have the followig structure: More...

Public Member Functions

bool RegisterOperation (Func< PeerBase, OperationRequest, SendParameters, OperationResponse > method)
 Registers a method to map by operation code. More...
 
bool RegisterOperation (MethodInfo method)
 Registers a method tp map by operation code. The method must have the following structure: More...
 
void RegisterOperations (Type targetType)
 Registers all methods of the targetType that are flagged with the OperationAttribute. Theses methods must have the following structure: More...
 

Detailed Description

This cache enables high performance mapping of operation codes to operations. It collaborates with the OperationDispatcher. Instances of this class should be reused if possible since the method registration is slower than the mapping. Registered methods must have the followig structure:

[Operation(OperationCode = 1)] OperationResponse MyMethod(PeerBase peer, OperationRequest request);

Member Function Documentation

bool Photon.SocketServer.Rpc.Reflection.OperationMethodInfoCache.RegisterOperation ( Func< PeerBase, OperationRequest, SendParameters, OperationResponse method)
inline

Registers a method to map by operation code.

Parameters
methodThe method to register.
Returns
true if successfully registered.
Exceptions
ArgumentExceptionmethod already registered
bool Photon.SocketServer.Rpc.Reflection.OperationMethodInfoCache.RegisterOperation ( MethodInfo  method)
inline

Registers a method tp map by operation code. The method must have the following structure:

[Operation(OperationCode = 1)] OperationResponse MyMethod(Peer peer, OperationRequest request);

Parameters
methodThe method to register.
Returns
true if successfully registered.
Exceptions
ArgumentExceptionmethod already registered
void Photon.SocketServer.Rpc.Reflection.OperationMethodInfoCache.RegisterOperations ( Type  targetType)
inline

Registers all methods of the targetType that are flagged with the OperationAttribute. Theses methods must have the following structure:

[Operation(OperationCode = 1)] OperationResponse MyMethod(Peer peer, OperationRequest request);

Parameters
targetTypeThe target Type.