heroku-python / flask-sockets

[DEPRECATED] Alternative: https://github.com/miguelgrinberg/flask-sock
MIT License
1.74k stars 167 forks source link

Documentation on sending binary data? #66

Closed d33tah closed 5 years ago

d33tah commented 5 years ago

I'd like to send binary data using this library, but I have no idea how to get there. So far I'm only getting encoding errors - probably because it's assumed that I'm sending ASCII strings. How to get around that?

colin-riddell commented 5 years ago

You may be able to provide socket.send() the argument Binary=True. Eg:

socket.send(payload,  Binary=True)
colin-riddell commented 5 years ago

Yes! Seems like you can. Ref: https://github.com/jgelens/gevent-websocket/blob/93d6b72a49742cfd615cc102a4c628acf2568465/geventwebsocket/websocket.py#L339

flask-sockets uses gevent-websocket interface thus uses their .send

d33tah commented 5 years ago

Awesome, thanks!