Skip to content

Implement web sockets in Hyperspace #161

Description

@GrandLarseny

This is more of a proposal to track adding support for web sockets to Hyperspace. I believe it would be an interesting use case that could be helpful.

Implementation

I propose adding a new class named WebSocketBackendService that conforms to BackendServiceProtocol. It will behave very similarly to BackendService, but will add two key functions.

func listen<T>(for type: T, perform: (T) -> Void) where T: Decodable
func send<T>(message: T) async throws

Alternatives Considered

I have considered registering decodable types in the service initializer, but I believe that losing the type information would be pretty rough in the implementation. I like how the above listen function would maintain type information which allows the implementers to treat listening to messages similarly to routing URLs.

Drawbacks

Bloat. Adding web sockets is a bit outside the initial scope of Hyperspace, but I believe it is appropriate for this framework since it's an Apple-supplied and supported API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions