Skip to content

Binary WebSocket Msgs #14

@JonathanILevi

Description

@JonathanILevi

Currently Lighttp does not work with binary messages, only text messages. It assumes outgoing msgs are text, and ignores incoming binary msgs.

According to the WebSocket spec, found here, page 28:

  • %x1 denotes a text frame
  • %x2 denotes a binary frame

To change your code to work only with binary simply change:

  • In WebSocketConnection.send, line 341, from 0b10000001 to 0b10000010
  • In WebSocketConnection.onRead, line 314, from == 1 to == 2

Obviously that is not a good fix.

Vibe.d has a receiveBinary and a receiveText, and overloads send with const(char)[] and const(ubyte[]) respectively.

Given that Lighttp uses a callback style, I recommend adding overloads to WebSocketConnection.send and WebSocketConnection.onReceive. It will be a breaking change, given that the current binary-signatured functions will actually send binary, not text.

I can make a Pull Request. Any reason why WebSocketConnection.send takes a void[] and not a ubyte[]?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions