socketry / async-websocket

Asynchronous WebSocket client and server, supporting HTTP/1 and HTTP/2 for Ruby.
MIT License
167 stars 18 forks source link

Library restricts possible data formats #9

Closed WA9ACE closed 5 years ago

WA9ACE commented 5 years ago

The form data takes across the websocket should be the responsibility of the application developer and not the library. In its current form you cannot use anything but JSON payloads removing the ability to send anything such as XML or ProtoBuffers across the wire.

ioquatix commented 5 years ago

It's now possible to do this if you just override these functions https://github.com/socketry/protocol-websocket/blob/master/lib/protocol/websocket/connection.rb#L168-L189

Additionally, you could even define your own frame types (violating the spec of course), and do whatever you want w.r.t. reading and writing frames, using @framer directly.

Make your own connection class and use Async::WebSocket::Client.open(..., connect: MyConnection) or Async::WebSocket::Server::Rack.open(env, connect: MyConnection).