New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support multiple servercontexts #629
Support multiple servercontexts #629
Conversation
f9248ac
to
257e322
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool how relatively few changes this needed now!
If there were multiple instances with e.g. different player services, would the player services be distinguishable in the logs?
Should there be tests for having multiple instances?
257e322
to
b521a4a
Compare
If there were multiple instances, you wouldn't be able to tell the difference in the log. Mostly i didn't bother with that since I really don't know why we would ever be running multiple server instances in the same process. I had considered actually forcing the |
b521a4a
to
77ccc26
Compare
a58b4cc
to
35382df
Compare
This class is capable of handling multiple attached ServerContext's correctly, enabling the server to listen on multiple ports with different Protocol implementations.
35382df
to
468fcb5
Compare
Refactors the server broadcasting code so that multiple ServerContext's can be run correctly at the same time. This will allow us to start working on a v2 version of the protocol which can concurrently with the legacy protocol. As a sample I've added a
SimpleJsonProtocol
class that sends each message as a json object followed by a newline.I think we should try to transition to the new protocol incrementally. As a first step, we can swap out the "transport" or "wire" layer from
QDataStream
toJson
, and keep everything else the same. We could implement this in the client and start using it immediately, which would cut the amount of network traffic in half (due to the legacy protocol using utf-16 encoding instead of utf-8). There isn't really a down side to doing this, as we can keep adding new incremental protocol versions on new ports. Hopefully with these refactors it will even be possible to implement a websocket protocol, but I haven't looked into the details of that yet. I just know that there is a websockets library in python that uses asyncio.