Pub Version

Game socket

The library was published in early access and is not stable, as it is being developed in parallel with other solutions. English is not a native language so there are no comments. At this stage, the library is for those who want to understand the source code and get a starting point for their solution or help me :)


  • One library contains both Server and Client parts.
  • The API communication library is similar to, but not compatible with this solution.
  • Contains a built-in binary protocol so you don't have to work at the byte level.
  • The transport layer uses TCP. To send game messages, it is planned to implement parallel work with UDP.
  • It implements such concepts as Multiplexing - interaction with several spaces through a single channel.

Support for WebSocket is not planned for the current day (but everything can change with the support of the community)




The protocol is schematic based. This approach allows you to save the amount of data transferred, since the data type is not transferred with the message, and the length of the numbers is not serialized.

Data types used in the schema

bool1 bittrue or false
int81 byte0 to 255
int162 bytes0 to 65535
int324 bytes0 to 4294967295
string1 + value0 to 255 chars
bytes2 + value0 to 65535 bytes

Data types when writing or reading messages

OperationSchema TypeDart TypeRange
putBoolboolbooltrue or false
putIntint8int-128 to 127
putUIntint8int0 to 255
putIntint16int-32768 to 32767
putUIntint16int0 to 65535
putIntint32int-2147483648 to 2147483647
putUIntint32int0 to 4294967295
putStringstringString0 to 255 chars
putSingleint8double0 to 1 step ~0.004
putRadiansint16doublestep ~0.0002
putPayloadbytesUint8List0 to 65535 bytes


  • Initialization for sending UPD diagrams.
  • Automatic connections and reconnections.
  • Expanding the possibilities for working with rooms.
  • Conducting stress tests.

Tips for Beginners

  • If you are developing a browser game, then you need a WebSocket solution.
  • When designing a game for real-time communication, UDP should be preferred, sinceTCP will cause a delay in the event of packet loss.

History of creation

Sources that could have influenced the development of this work:

If you can suggest a translation better than automatic ᕙ(☉̃ₒ☉‶)ว just do it