walkor / phpsocket.io

A server side alternative implementation of socket.io in PHP based on workerman.
2.28k stars 509 forks source link

How to use socket.io with Protobuf ? #302

Open ouroboros17 opened 4 months ago

ouroboros17 commented 4 months ago

Hello, I have been using your library for websockets for a while now and now I have a need to pass binary data to Protobuf, how to implement this?

Awesome-T commented 4 months ago

Hello, I have been using your library for websockets for a while now and now I have a need to pass binary data to Protobuf, how to implement this?

Hi there! Of course, you can send binary data using various methods, such as WebSockets, REST, and so on. For example, take a look at the WebSockets method, which takes either a byte or a string argument. You will need to call this method from your DT model, which is created by the Protocol Utility's writeToBuffer(). After that, you will want to add this array to your WebSocket send method.

[https://pub.dev/documentation/protobuf/latest/protobuf/GeneratedMessage/writeToBuffer.html

https://api.flutter.dev/flutter/dart-io/WebSocket/add.html