Photon Bolt Engine API
Networking Middleware
Public Member Functions | Properties | List of all members
Bolt.Event Class Reference

Base class that all events inherit from More...

Inheritance diagram for Bolt.Event:

Public Member Functions

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

Properties

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

◆ Send()

void 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 [] 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 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 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);
}
}

◆ RaisedBy

BoltConnection 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);
}