ServerBytes Server SDK enables dispatching of events to other plugins.

Events defined by ServerBytes SDK are:

  • UserConnected
  • UserDisconnected
  • UserAuthenticated
  • UserDisplayNameUpdated
  • UserLoggedOut

To define your event, create a class which inherits from IEvent.

Dispatching the event happens on immediately, on a different thread. The event processing thread has no knowledge about the user who dispatched this event.

To dispatch an event, use Event.Dispatch(IEvent @event) method.

To subscribe to an event, create a handler which inherits from IEventHandler<T>, and register it in PluginStartup file.


using ServerBytes.PluginSDK.Server.Events;

// Create event class
public class MyEvent : IEvent
    public string Data { get; }
    public MyEvent (string data) 
        Data = data;

// Create the handler
public class MyEventHandler : IEventHandler<MyEvent>
    Task Handle(MyEvent @event)
        // process event

// Register the handler
public class PluginStartup : IPluginStartup
    public void ConfigureServices(IServiceCollection services, IConfiguration config)
        // ...
        services.AddSingleton<IEventHandler<MyEvent>, MyEventHandler>();

// Dispatch the event in your code

var myEvent = new MyEvent("data");

results matching ""

    No results matching ""