Photon Plugins API Documentation
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 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 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...
 

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

Detailed Description

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

Member Function Documentation

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
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
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
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
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
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
EnvironmentVersion Photon.Hive.Plugin.IPluginHost.GetEnvironmentVersion ( )

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

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
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
void Photon.Hive.Plugin.IPluginHost.LogDebug ( object  message)

Add log entry at debug level.

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

Add log entry at error level.

Parameters
messagemessage to log
void Photon.Hive.Plugin.IPluginHost.LogFatal ( object  message)

Add log entry at fatal level.

Parameters
messagemessage to log
void Photon.Hive.Plugin.IPluginHost.LogInfo ( object  message)

Add log entry at info level.

Parameters
messagemessage to log
void Photon.Hive.Plugin.IPluginHost.LogWarning ( object  message)

Add log entry at warning level.

Parameters
messagemessage to log
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.
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.
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.
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
void Photon.Hive.Plugin.IPluginHost.StopTimer ( object  timer)

Stop a timer.

Parameters
timerThe timer to stop.
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

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.

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

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

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.

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

List of active actors in game.

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

List of inactive active actors in game.

string Photon.Hive.Plugin.IPluginHost.GameId
get

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

Hashtable Photon.Hive.Plugin.IPluginHost.GameProperties
get

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

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.