Skip to content

Add ability to send pre-serialized data for efficiency #5339

@davidfowl

Description

@davidfowl

There's a pattern where you're sending data that's already serialized from another system (like a message bus) to the clients without first de-serializing and re-serializing. Here's an example:

https://github.com/gcsuk/Achievements/blob/f54479ca595bcf62fa17177b0ec101a7b918d8a5/src/Achievements/Achievements/EventListener.cs#L66-L76

The above code gets a utf8 JSON encoded message from the queue, turns it into a string, then turns that string into a UserAchievement<string> object. Then it calls IHubContext.User(...).SendAsync which turns that object back into a utf8 byte[] payload to send on the wire.

We should introduce a new type that encodes this information that IHubProtocols have native support for. Some considerations:

  • If connected clients are various protocols, what do we do? Do we store type information so that we can de-serialize in the original format and re-serialize in the correct format?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: DesignThis issue requires design work before implementating.area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions