NFIBrokerage / slipstream

A slick WebSocket client for Phoenix Channels
https://hex.pm/packages/slipstream
Apache License 2.0
160 stars 18 forks source link

Allow pushing binary data #53

Closed the-mikedavis closed 1 year ago

the-mikedavis commented 1 year ago

Slipstream.push/5 should allow pushing binary data as a binary WebSocket frame. The same is allowed on the server side (docs). The typespec should become:

 @spec push(
         socket :: Socket.t(),
         topic :: String.t(),
         event :: String.t(),
-        params :: json_serializable(),
+        params :: json_serializable() | {:binary, binary()},
         timeout :: timeout()
       ) :: {:ok, push_reference()} | {:error, reason :: term()}

and anything passed in as {:binary, data} should not be passed through the serializer.

See https://github.com/NFIBrokerage/slipstream/issues/28#issuecomment-1477998841