onEvent

Event

Event that triggers when a remote event is received

Returns INetworkingRemoteEventsService.OnEventDelegate

Examples

const byte EVENT_ID = 8;// A byte unique to this event

void OnEnable()
{
// Register listener for incoming network events
SpatialBridge.networkingService.remoteEvents.onEvent += HandleEvent;
}

void OnDisable()
{
SpatialBridge.networkingService.remoteEvents.onEvent -= HandleEvent;
}

void HandleEvent(NetworkingRemoteEventArgs args)
{
// Parse all incoming network events. Check for the correct ID
if (args.eventID == EVENT_ID)
{
// Display the message
SpatialBridge.coreGUIService.DisplayToastMessage((string)args.eventArgs[0]);
}
}

public void SendEventToAllPlayers()
{
// Send a network event to all players
SpatialBridge.networkingService.remoteEvents.RaiseEventAll(EVENT_ID, "Greetings!");
}
const byte EVENT_ID = 8;// A byte unique to this event

void OnEnable()
{
// Register listener for incoming network events
SpatialBridge.networkingService.remoteEvents.onEvent += HandleEvent;
}

void OnDisable()
{
SpatialBridge.networkingService.remoteEvents.onEvent -= HandleEvent;
}

void HandleEvent(NetworkingRemoteEventArgs args)
{
// Parse all incoming network events. Check for the correct ID
if (args.eventID == EVENT_ID)
{
// Display the message
SpatialBridge.coreGUIService.DisplayToastMessage((string)args.eventArgs[0]);
}
}

public void SendEventToAllPlayers()
{
// Send a network event to all players
SpatialBridge.networkingService.remoteEvents.RaiseEventAll(EVENT_ID, "Greetings!");
}