Photon Bolt Engine API 1.3

Public Member Functions | Protected Member Functions | Properties | List of all members
Photon.Bolt.Event Class Reference

Base class that all events inherit from More...

Inheritance diagram for Photon.Bolt.Event:

Public Member Functions

void Send ()
 Enqueue this object for sending across the network More...
 

Protected Member Functions

virtual void PrepareRelease ()
 The Event implementation overrides this method to release any pending data that can be pooled, like IProtocolToken references More...
 

Properties

byte[] BinaryData [get, set]
 The raw bytes of the event data More...
 
bool FromSelf [get]
 Returns true if this event was sent from own connection More...
 
bool IsGlobalEvent [get]
 Returns true if this is a global event / not an entity event More...
 
BoltConnection RaisedBy [get]
 The connection which raised this event More...
 

Detailed Description

Base class that all events inherit from

Example: Using a LogEvent object to send a message.

void LogMessage(string message) {
var logEvt = new LogEvent();
logEvt.message = message;
logEvt.Send();
}

Member Function Documentation

◆ PrepareRelease()

virtual void Photon.Bolt.Event.PrepareRelease ( )
inlineprotectedvirtual

The Event implementation overrides this method to release any pending data that can be pooled, like IProtocolToken references

◆ Send()

void Photon.Bolt.Event.Send ( )
inline

Enqueue this object for sending across the network

Example: Sending a log message.

void LogMessage(string message) {
var logEvt = new LogEvent();
logEvt.message = message;
logEvt.Send();
}

Property Documentation

◆ BinaryData

byte [] Photon.Bolt.Event.BinaryData
getset

The raw bytes of the event data

Example: Removing repeated chat messages by doing sequence comparison on the raw byte data and filtering out any repeated messages after a certain limit.

public override void OnEvent(ChatEvent chatEvt) {
bool repeated = true;
for(int i = 0; i < CHAT_REPEAT_LIMIT; i++) {
if(!chatEvt.BinaryData.SequenceEqual(previousChatEvts.GoBack(i).BinaryData) {
repeated = false;
break;
}
}
}

◆ FromSelf

bool Photon.Bolt.Event.FromSelf
get

Returns true if this event was sent from own connection

Example: Showing chat messages from other players.

public override void OnEvent(ChatEvent chatEvt) {
if(chatEvt.FromSelf) {
return;
}
ChatWindow.instance.ShowMessage(chatEvt.message, chatEvt.timestamp);
}


◆ IsGlobalEvent

bool Photon.Bolt.Event.IsGlobalEvent
get

Returns true if this is a global event / not an entity event

Example: Using the isGlobal property to determine whether to send local or whole-zone chat.

public override void OnEvent(ChatEvent chatEvt) {
if(chatEvt.isGlobalEvent) {
BroadcastZoneChat(chatEvt.message, chatEvt.timestamp);
}
else {
SendLocalChat(chatEvt.message, chatEvt.timestamp);
}
<br>
}

◆ RaisedBy

BoltConnection Photon.Bolt.Event.RaisedBy
get

The connection which raised this event

Example: Blocking messages from players on a chat restricted list.

public override void OnEvent(ChatEvent chatEvt) {
if(chatRestrictedPlayerList.ContainsKey(chatEvt.RaisedBy)) {
return;
}
ChatWindow.instance.ShowMessage(chatEvt.message, chatEvt.timestamp);
}