Skip to content

Question: Any way to safely get a ReadWriteCloser compatible with x/net/websocket? #282

Closed
@prasannavl

Description

@prasannavl

I'm trying to port https://github.com/rsms/gotalk to use gorilla websockets instead of x/net/websocket. However, it uses a common underlying handler for both the raw TCP stream, and websockets stream. The websockets one uses /x/net/websocket where it upgrades the connection, and the passes it on to the raw TCP handler, that handles things from there.

To be able to do this, x/net/websocket is pretty trivial. All it does is exposes the Conn after the upgrade that can be sent as a ReadWriteCloser. I'm wondering if it's possible to achieve this using Gorilla websockets, while still retaining the higher level features like compression that gorilla socket provides. From what little I looked under the hood, it only seems to have the raw underlying connection conn which cannot be passed since it will include the websocket framing, and reader and writer which are exposed through NextReader and NextWriter which can change. Any way to do this without writing a complicated abstraction layer on top of NextReader/NextWriter?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions