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.

1 void LogMessage(string message) {
2  var logEvt = new LogEvent();
3  logEvt.message = message;
4  logEvt.Send();
5 }

Member Function Documentation

void Bolt.Event.Send ( )
inline

Enqueue this object for sending across the network

Example: Sending a log message.

1 void LogMessage(string message) {
2  var logEvt = new LogEvent();
3  logEvt.message = message;
4  logEvt.Send();
5 }

Property Documentation

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.

1 public override void OnEvent(ChatEvent chatEvt) {
2  bool repeated = true;
3 
4  for(int i = 0; i < CHAT_REPEAT_LIMIT; i++) {
5  if(!chatEvt.BinaryData.SequenceEqual(previousChatEvts.GoBack(i).BinaryData) {
6  repeated = false;
7  break;
8  }
9  }
10 
11 
12 }
bool Bolt.Event.FromSelf
get

Returns true if this event was sent from own connection

Example: Showing chat messages from other players.

1 public override void OnEvent(ChatEvent chatEvt) {
2  if(chatEvt.FromSelf) {
3  return;
4  }
5 
6  ChatWindow.instance.ShowMessage(chatEvt.message, chatEvt.timestamp);
7 }
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.

1 public override void OnEvent(ChatEvent chatEvt) {
2  if(chatEvt.isGlobalEvent) {
3  BroadcastZoneChat(chatEvt.message, chatEvt.timestamp);
4  }
5  else {
6  SendLocalChat(chatEvt.message, chatEvt.timestamp);
7  }
8 }
BoltConnection Bolt.Event.RaisedBy
get

The connection which raised this event

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

1 public override void OnEvent(ChatEvent chatEvt) {
2  if(chatRestrictedPlayerList.ContainsKey(chatEvt.RaisedBy)) {
3  return;
4  }
5 
6  ChatWindow.instance.ShowMessage(chatEvt.message, chatEvt.timestamp);
7 }