Skip to content

Should the client support custom events? #2

@apkrieg

Description

@apkrieg

In the current implementation, all events are dispatched to OnMessage. This means you'd have to use your own conditional logic like a switch statement to direct traffic like:

public void OnMessage(ServerSentEvent ev)
{
    switch (ev.Event)
    {
        case "my-event":
            // ...
            break;
        default:
            // ...
            break;
    }
}

The proposal here is to add a CustomEvents dictionary to the client. If a key exists for the event type in the dictionary, it will be dispatched to that handler and not OnMessage. If no handler exists in the dictionary, OnMessage would be invoked.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions