VedalAI / neuro-amongus

Among Us Plugin for Neuro-sama
GNU General Public License v3.0
540 stars 49 forks source link

External Communication Protocol #15

Closed Morgul closed 1 year ago

Morgul commented 1 year ago

Found myself thinking about this:

We will also probably want a separate class in the future to interface with the Python neural network, probably just open a socket and have some sort of communication protocol. This may end up being a different plugin(?), that instead just uses the data collected from this plugin to interface with the neural network. (From #4)

My recommendation (from personal experience) would be to send JSON (Or, msgpack, if that's chosen for the recording plugin) wrapped in a netstring:

30:{"msg":"Hello","name":"World"},

The format is, simply: <Length>:<Message>, where <Length> is the length of <Message>. The : and , are convention, but could be any predetermined characters. (Also, there's no need to escape the message contents which is a huge plus.)

Implementing netstrings is pretty straight forward, and I've done it in about a dozen languages at this point. They're pretty resilient, fast, and simple to understand. Even better, we can implement this 100% natively in both C# and python.

If this seems like a reasonable direction, I'll do up a C# implementation and a simple python test server for it, as a proof of concept.

Alexejhero commented 1 year ago

We discussed about the implementation for the communication protocol and we came to the conclusion that the best idea would be using a binary serializer, that way we avoid including the object keys and save bandwidth and storage space.

Actually we're using Protobuf now.