WebSockets for WebAdmin

UKGamerUKGamer 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?

Comments

  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    When I was writing all the new webadmin code, we really needed a simple way of exchanging this information. The periodic AJAX requests work fairly well, and more importantly was easy to implement and understand server side.

    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.
  • GuspazGuspaz Join Date: 2002-11-01 Member: 2862Members, Constellation
    There are simpler ways to accomplish this anyhow. Blocking requests comes to mind; make an asynchronous request to the server, which blocks until there is a new piece of data to return. So you could start a request to the server, which would block until there was another chat request, then immediately return.

    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.
Sign In or Register to comment.