Skip to main content
Version: Next

Local events

Things happen all the time not just on the server side. They can be tracked, with EventListeners.

Registering an EventListener

The first parametes is the event's name, the second is it's callback function. You don't have to worry about registering a function with wrong parameters. All of them are staticly typed.

client.addEventListener("onStatusChange", (newStauts: WSStatus) =>{
console.log(newStauts); //Enum
});

OR

This will only get executed once.

client.onceEventListener("onStatusChange", (newStauts: WSStatus) => {
console.log(newStauts); //Enum
});

Currently available event types

  • onStatusChange
    • Runs when the connection status changes
  • onMessageRecieved
    • Runs after the client processes a newly recieved message
  • onRawMessageRecieved
    • Runs before the client processes a newly recieved message
  • onCookieSet
    • Runs when the server sends down one or multiple new cookies.
  • onCookieDelete
    • Runs when the server deletes a cookie