Photon Plugins API Documentation v5.0RC1

Public Member Functions | Properties | List of all members
Photon.Hive.Plugin.IPluginHost Interface Reference

Base interface that should be implemented as a wrapper of the game that is hosting the plugin instance. More...

Public Member Functions

void BroadcastEvent (IList< int > recieverActors, int senderActor, byte evCode, Dictionary< byte, object > data, byte cacheOp, SendParameters sendParameters=new SendParameters())
 Send event to a specific list of actors inside the room or update events cache. More...
 
void BroadcastEvent (byte target, int senderActor, byte targetGroup, byte evCode, Dictionary< byte, object > data, byte cacheOp, SendParameters sendParameters=new SendParameters())
 Send event to a predefined target group of actors inside the room or update events cache. More...
 
void BroadcastErrorInfoEvent (string message, SendParameters sendParameters=new SendParameters())
 Used to inform clients of errors. If a callInfo is available in the context of the error then the overload with info should be used. More...
 
void BroadcastErrorInfoEvent (string message, ICallInfo info, SendParameters sendParameters=new SendParameters())
 Used to inform clients of errors. More...
 
object CreateOneTimeTimer (Action callback, int dueTimeMs)
 Creates a timer that triggers a callback once dueTimeMs elapses. Callbacks are called in the context the room fiber. More...
 
object CreateOneTimeTimer (ICallInfo info, Action callback, int dueTimeMs)
 
object CreateTimer (Action callback, int dueTimeMs, int intervalMs)
 Creates a timers that triggers a callback once dueTimeMs elapses and repeats the callback every intervalMs. Callbacks are called in the context the room fiber. More...
 
SerializableGameState GetSerializableGameState ()
 The serializable game state can be used to recreate the room after it gets removed from memory. Also SetGameState. More...
 
void HttpRequest (HttpRequest request)
 The recommend way to make http requests to external systems. The http call is completly async, but it returns the result in a fiber compatible way. There are two modes for recieving a reponse: More...
 
void HttpRequest (HttpRequest request, ICallInfo info)
 
void LogDebug (object message)
 Add log entry at debug level. More...
 
void LogError (object message)
 Add log entry at error level. More...
 
void LogFatal (object message)
 Add log entry at fatal level. More...
 
void LogInfo (object message)
 Add log entry at info level. More...
 
void LogWarning (object message)
 Add log entry at warning level. More...
 
bool SetGameState (SerializableGameState state)
 Assign a loaded/external game state to the room. More...
 
bool SetProperties (int actorNr, Hashtable properties, Hashtable expected, bool broadcast)
 Set properties (well known or custom) of the room or an actor. More...
 
void StopTimer (object timer)
 Stop a timer. More...
 
bool RemoveActor (int actorNr, string reasonDetail)
 Remove an actor from the room's actors list and add to excluded actors list. More...
 
bool RemoveActor (int actorNr, byte reason, string reasonDetail)
 Remove an actor from the room's actors list and add to excluded actors list. More...
 
bool TryRegisterType (Type type, byte typeCode, Func< object, byte[]> serializeFunction, Func< byte[], object > deserializeFunction)
 Registers new types/classes for de/serialization and the fitting methods to call for this type. More...
 
EnvironmentVersion GetEnvironmentVersion ()
 Returns EnvironmentVersion object which contains version of PhotonHivePlugin at build time and currently running More...
 
IPluginLogger CreateLogger (string name)
 
void Enqueue (Action action)
 Enqueues action into rooms fiber. this guarnties thread safe access to rooms and plugins data More...
 
bool ExecuteCacheOperation (CacheOp operation, out string errorMsg)
 this methods allows to execute any cache operation. it can not be used to send user events to send user events use BroadcastEvent More...
 
IPluginFiber GetRoomFiber ()
 Get the reference which helps to enqueue actions to rooms fiber this reference does same as methods presenting in IPluginHost, but without need of ICallInfo and checks whether ICallInfo methods called More...
 

Properties

Dictionary< string, object > Environment [get]
 Should contain game and application global properties (AppId, AppVersion, Cloud, Region, etc.) More...
 
IList< IActorGameActors [get]
 List of all actors in game - including active and inactive. With each actor having a flag IsInactive IActor. More...
 
IList< IActorGameActorsActive [get]
 List of active actors in game. More...
 
IList< IActorGameActorsInactive [get]
 List of inactive active actors in game. More...
 
string GameId [get]
 Unique game identifier. Called Roomname in most client sdk's. More...
 
Hashtable GameProperties [get]
 Game properties as set through the client per RoomOptions.CustomRoomProperties. More...
 
Dictionary< string, object > CustomGameProperties [get]
 The game properties that are published to the lobby - as defined by clients per RoomOptions.CustomRoomPropertiesForLobby. More...
 
int MasterClientId [get]
 The actor number of the client defined as master. If the client disconnects a new master client will be selected by photon. Changes in the master client id are notified per PluginBase.OnChangeMasterClientId. More...
 
bool IsSuspended [get]
 
bool IsSyspended [get]
 

Detailed Description

Base interface that should be implemented as a wrapper of the game that is hosting the plugin instance.

Member Function Documentation

◆ BroadcastErrorInfoEvent() [1/2]

void Photon.Hive.Plugin.IPluginHost.BroadcastErrorInfoEvent ( string  message,
ICallInfo  info,
SendParameters  sendParameters = new SendParameters() 
)

Used to inform clients of errors.

Parameters
messageerror description
infoexpected to be a callInfo in the error context, used for logging purposes
sendParametersparamters which defines how event will be sent

◆ BroadcastErrorInfoEvent() [2/2]

void Photon.Hive.Plugin.IPluginHost.BroadcastErrorInfoEvent ( string  message,
SendParameters  sendParameters = new SendParameters() 
)

Used to inform clients of errors. If a callInfo is available in the context of the error then the overload with info should be used.

Parameters
messageerror description
sendParametersparamters which defines how event will be sent

◆ BroadcastEvent() [1/2]

void Photon.Hive.Plugin.IPluginHost.BroadcastEvent ( byte  target,
int  senderActor,
byte  targetGroup,
byte  evCode,
Dictionary< byte, object >  data,
byte  cacheOp,
SendParameters  sendParameters = new SendParameters() 
)

Send event to a predefined target group of actors inside the room or update events cache.

Parameters
targetThe group type. ReciverGroup
senderActorThe origin of this event.
  • 0 if it should be the room itself (authorative event).
  • an actual actor number to impersonate.
targetGroupTarget interest group.
evCodeEvent code.
dataEvent data.
cacheOpCaching option. CacheOperations
sendParametersSendParameters

◆ BroadcastEvent() [2/2]

void Photon.Hive.Plugin.IPluginHost.BroadcastEvent ( IList< int >  recieverActors,
int  senderActor,
byte  evCode,
Dictionary< byte, object >  data,
byte  cacheOp,
SendParameters  sendParameters = new SendParameters() 
)

Send event to a specific list of actors inside the room or update events cache.

Parameters
recieverActorsNumbers of actors that should receive the event.
senderActorThe origin of this event.
  • 0 if it should be the room itself (authorative event).
  • an actual actor number to impersonate.
evCodeEvent code.
dataEvent data.
cacheOpCaching option. CacheOperations
sendParametersSendParameters

◆ CreateLogger()

IPluginLogger Photon.Hive.Plugin.IPluginHost.CreateLogger ( string  name)

◆ CreateOneTimeTimer() [1/2]

object Photon.Hive.Plugin.IPluginHost.CreateOneTimeTimer ( Action  callback,
int  dueTimeMs 
)

Creates a timer that triggers a callback once dueTimeMs elapses. Callbacks are called in the context the room fiber.

Parameters
callbackAction called when timer is triggered
dueTimeMsTime for callback to elapse
Returns
a timer object which can be canceld using StopTimer

◆ CreateOneTimeTimer() [2/2]

object Photon.Hive.Plugin.IPluginHost.CreateOneTimeTimer ( ICallInfo  info,
Action  callback,
int  dueTimeMs 
)

◆ CreateTimer()

object Photon.Hive.Plugin.IPluginHost.CreateTimer ( Action  callback,
int  dueTimeMs,
int  intervalMs 
)

Creates a timers that triggers a callback once dueTimeMs elapses and repeats the callback every intervalMs. Callbacks are called in the context the room fiber.

Parameters
callbackAction called when timer is triggered
dueTimeMsTime for callback to elapse
intervalMsintervall for callbacks to be called
Returns
a timer object which can be canceld using StopTimer

◆ Enqueue()

void Photon.Hive.Plugin.IPluginHost.Enqueue ( Action  action)

Enqueues action into rooms fiber. this guarnties thread safe access to rooms and plugins data

Parameters
action

◆ ExecuteCacheOperation()

bool Photon.Hive.Plugin.IPluginHost.ExecuteCacheOperation ( CacheOp  operation,
out string  errorMsg 
)

this methods allows to execute any cache operation. it can not be used to send user events to send user events use BroadcastEvent

Parameters
operationset of parameters to perform operation
errorMsgerror message if any
Returns
true in case of success. false otherwise

◆ GetEnvironmentVersion()

EnvironmentVersion Photon.Hive.Plugin.IPluginHost.GetEnvironmentVersion ( )

Returns EnvironmentVersion object which contains version of PhotonHivePlugin at build time and currently running

◆ GetRoomFiber()

IPluginFiber Photon.Hive.Plugin.IPluginHost.GetRoomFiber ( )

Get the reference which helps to enqueue actions to rooms fiber this reference does same as methods presenting in IPluginHost, but without need of ICallInfo and checks whether ICallInfo methods called

Returns

◆ GetSerializableGameState()

SerializableGameState Photon.Hive.Plugin.IPluginHost.GetSerializableGameState ( )

The serializable game state can be used to recreate the room after it gets removed from memory. Also SetGameState.

Returns
a serializable game state

◆ HttpRequest() [1/2]

void Photon.Hive.Plugin.IPluginHost.HttpRequest ( HttpRequest  request)

The recommend way to make http requests to external systems. The http call is completly async, but it returns the result in a fiber compatible way. There are two modes for recieving a reponse:

  • sync: this means effectivly pausing the fiber until the response is received. And where the callback is called before HttpRequest returns.
  • async: HttpRequest will return immediately. Messages in the room fiber will continue to be processed. The response is enqueued in the room fiber.
Parameters
request

◆ HttpRequest() [2/2]

void Photon.Hive.Plugin.IPluginHost.HttpRequest ( HttpRequest  request,
ICallInfo  info 
)

◆ LogDebug()

void Photon.Hive.Plugin.IPluginHost.LogDebug ( object  message)

Add log entry at debug level.

Parameters
message

◆ LogError()

void Photon.Hive.Plugin.IPluginHost.LogError ( object  message)

Add log entry at error level.

Parameters
messagemessage to log

◆ LogFatal()

void Photon.Hive.Plugin.IPluginHost.LogFatal ( object  message)

Add log entry at fatal level.

Parameters
messagemessage to log

◆ LogInfo()

void Photon.Hive.Plugin.IPluginHost.LogInfo ( object  message)

Add log entry at info level.

Parameters
messagemessage to log

◆ LogWarning()

void Photon.Hive.Plugin.IPluginHost.LogWarning ( object  message)

Add log entry at warning level.

Parameters
messagemessage to log

◆ RemoveActor() [1/2]

bool Photon.Hive.Plugin.IPluginHost.RemoveActor ( int  actorNr,
byte  reason,
string  reasonDetail 
)

Remove an actor from the room's actors list and add to excluded actors list.

Parameters
actorNrThe number, inside the room, of the actor to remove.
reasonA code for the reason. RemoveActorReason
reasonDetailA more detailed message explaining why the actor is removed.
Returns
If the actor removal is successful.

◆ RemoveActor() [2/2]

bool Photon.Hive.Plugin.IPluginHost.RemoveActor ( int  actorNr,
string  reasonDetail 
)

Remove an actor from the room's actors list and add to excluded actors list.

Parameters
actorNrThe number, inside the room, of the actor to remove.
reasonDetailA more detailed message explaining why the actor is removed.
Returns
If the actor removal is successful.

◆ SetGameState()

bool Photon.Hive.Plugin.IPluginHost.SetGameState ( SerializableGameState  state)

Assign a loaded/external game state to the room.

Parameters
stateserialzed state to affect to the room
Returns
If the room state was assigned to the room successfully.

◆ SetProperties()

bool Photon.Hive.Plugin.IPluginHost.SetProperties ( int  actorNr,
Hashtable  properties,
Hashtable  expected,
bool  broadcast 
)

Set properties (well known or custom) of the room or an actor.

Parameters
actorNrSet to 0 if the properties belong to the room, the target actor number otherwise.
propertiesThe properties to be updated. Null values to delete. Keys can be existent already or new.
expectedThe properties expected when update occurs. (CAS : "Check And Swap")
broadcastIndicates whether to send the PropertiesChanged event to other actors or not.
Returns

◆ StopTimer()

void Photon.Hive.Plugin.IPluginHost.StopTimer ( object  timer)

Stop a timer.

Parameters
timerThe timer to stop.

◆ TryRegisterType()

bool Photon.Hive.Plugin.IPluginHost.TryRegisterType ( Type  type,
byte  typeCode,
Func< object, byte[]>  serializeFunction,
Func< byte[], object >  deserializeFunction 
)

Registers new types/classes for de/serialization and the fitting methods to call for this type.

Parameters
typecustom (class) type to register.
typeCodeA byte-code used as shortcut during transfer of this type.
serializeFunctionSerialization method delegate to create a byte[] from a customType instance.
deserializeFunctionDeserliazation Method delegate to create customType instance from a byte[].
Returns
If the Type was registered successfully.

SerializeMethod and DeserializeMethod are complementary: Feed the product of serializeMethod to the constructor, to get a comparable instance of the object. After registering a Type, it can be used in events and operations and will be serialized like built-in types.

Property Documentation

◆ CustomGameProperties

Dictionary<string, object> Photon.Hive.Plugin.IPluginHost.CustomGameProperties
get

The game properties that are published to the lobby - as defined by clients per RoomOptions.CustomRoomPropertiesForLobby.

◆ Environment

Dictionary<string,object> Photon.Hive.Plugin.IPluginHost.Environment
get

Should contain game and application global properties (AppId, AppVersion, Cloud, Region, etc.)

◆ GameActors

IList<IActor> Photon.Hive.Plugin.IPluginHost.GameActors
get

List of all actors in game - including active and inactive. With each actor having a flag IsInactive IActor.

◆ GameActorsActive

IList<IActor> Photon.Hive.Plugin.IPluginHost.GameActorsActive
get

List of active actors in game.

◆ GameActorsInactive

IList<IActor> Photon.Hive.Plugin.IPluginHost.GameActorsInactive
get

List of inactive active actors in game.

◆ GameId

string Photon.Hive.Plugin.IPluginHost.GameId
get

Unique game identifier. Called Roomname in most client sdk's.

◆ GameProperties

Hashtable Photon.Hive.Plugin.IPluginHost.GameProperties
get

Game properties as set through the client per RoomOptions.CustomRoomProperties.

◆ IsSuspended

bool Photon.Hive.Plugin.IPluginHost.IsSuspended
get

◆ IsSyspended

bool Photon.Hive.Plugin.IPluginHost.IsSyspended
get

◆ MasterClientId

int Photon.Hive.Plugin.IPluginHost.MasterClientId
get

The actor number of the client defined as master. If the client disconnects a new master client will be selected by photon. Changes in the master client id are notified per PluginBase.OnChangeMasterClientId.