WebSockets for WebAdmin
UKGamer
Join Date: 2004-03-12 Member: 27300Members
<div class="IPBDescription">Has this been considered?</div>Hey all, I was just wondering if, instead of the current system of continuously polling the NS2 web server for game information every few seconds, there could be a single WebSocket connection to the server? This would eliminate the rather inefficient frequent polling and would also allow information to be transferred instantly rather than with each update (or command sent).
I understand that not all browsers support WebSockets but you could always fall back to the old polling method if it was not supported in the client's browser.
Has anyone tried implementing this? Has this idea already crossed the devs before? Is there some limitation preventing it from being added?
I understand that not all browsers support WebSockets but you could always fall back to the old polling method if it was not supported in the client's browser.
Has anyone tried implementing this? Has this idea already crossed the devs before? Is there some limitation preventing it from being added?
Comments
The polling is "inefficient" but, so what? The webserver runs in it's own thread, and it's very, very unlikely that you would see any decrease in performance or increase in load just because you have a bunch of people polling periodically.
Implementing websockets would require significant time, it's not just wave a magic wand and convert everything over to websockets. You have to design a custom protocol and implement it in both the C++ on the server and the Javascript on the client. That's a pretty big time investment to eliminate a max 3 second delay on actions occurring.
Do you really watch rcon 24/7 with your full attention? Do you regularly notice the 3 second delay on player updates (2 second on chat)? In my opinion, the delay really isn't anything that is causing enough problems to warrant the amount of time necessary to switch it.
It's pretty unlikely anyone would be able to implement this without engine changes. IIRC they use <a href="http://code.google.com/p/mongoose/" target="_blank">http://code.google.com/p/mongoose/</a> as the server library, and while that does support websockets, the functionality is not exposed to Lua.
There are a few circumstances involving players interacting with an external "bot" that interfaces via the web API that I could see this being VERY useful for.