Closed liaohongxing closed 4 months ago
Hi @liaohongxing here's how socketio manages this. By default websocket protocol defines the datatype. More information about this can be found here https://www.rfc-editor.org/rfc/rfc6455.html#section-11.8
Code reference Gorilla WebSocket https://github.com/gorilla/websocket/blob/main/conn.go#L61 Code reference for socketio fiber https://github.com/gofiber/contrib/blob/main/socketio/socketio.go#L16
Needs to be mentioned that this implementation supports read/write only text/byte data, like JSON, strings and every type that can be converted to []byte/string/text
Thanks for your quick response, I read your tip carefully.
The EventPayload callback seems to lack a flag to distinguish the two message types
For example, I want to receive messages and files in the callback, how can I do it?
Hi @liaohongxing as I mentioned, there is no need to check the message type, because this implementation supports only WebsocketMessageType = 1 (Text Message). The solution for your problem can be pretty simple using Base64 to encode the file, depending on your implementation.
Well. I think I know how to do it. thank you
Question Description
@antoniodipinto
Code Snippet (optional)
Checklist: