Way back yonder when things were a lot simpler, we created the footings for SSE (Server-Sent Events) broadcasting, with the intention that this channel would be how the backend alerts the frontend to things, without the frontend have to poll for it. We uh, never used it.... UNTIL NOW
This is a simple implementation, but it lays a lot of ground work that would make copy pasting further SSE broadcasting quite the easier process.
We broadcast 3 subtypes of ConsoleOutput messages - ChatMessage events, Kill events, and DemoStop events. These are broadcast to subscribers as a JSON blob that looks something like the follow:
Note that in the above PlayerKill example, WITCH is a bot, and thus doesnt have a steamID (so null is perfectly expected).
The intention is to use this same framework to broadcast votes to the frontend so it can display votes, vote options, and who voted for what, etc etc.
Use cases for the current messages? Cute little pop ups in the corner or something that show these things, to display game state and also useful as a meter for whether or not the client is actually properly reading TF2 data. Also, its COOL.
The code is a bit messy, so please eat me alive. Thanks.
FOR TESTING
You can use the python package requests-sse to subscribe to SSE endpoints and display messages as they come in. I have a short demo module (that is literally copy pasted sample code from the PyPI page for requests-sse, wrapped in a poetry project) that you can use: https://github.com/lili7h/http-sse-event-viewer
Way back yonder when things were a lot simpler, we created the footings for SSE (Server-Sent Events) broadcasting, with the intention that this channel would be how the backend alerts the frontend to things, without the frontend have to poll for it. We uh, never used it.... UNTIL NOW
This is a simple implementation, but it lays a lot of ground work that would make copy pasting further SSE broadcasting quite the easier process.
We broadcast 3 subtypes of ConsoleOutput messages - ChatMessage events, Kill events, and DemoStop events. These are broadcast to subscribers as a JSON blob that looks something like the follow:
Note that in the above PlayerKill example, WITCH is a bot, and thus doesnt have a steamID (so null is perfectly expected).
The intention is to use this same framework to broadcast votes to the frontend so it can display votes, vote options, and who voted for what, etc etc.
Use cases for the current messages? Cute little pop ups in the corner or something that show these things, to display game state and also useful as a meter for whether or not the client is actually properly reading TF2 data. Also, its COOL.
The code is a bit messy, so please eat me alive. Thanks.
FOR TESTING
You can use the python package
requests-sse
to subscribe to SSE endpoints and display messages as they come in. I have a short demo module (that is literally copy pasted sample code from the PyPI page for requests-sse, wrapped in a poetry project) that you can use: https://github.com/lili7h/http-sse-event-viewer