this is in coding help because you guys are cooler than modification discussion
Torque Webserver
Script Iterations:*
Version 1 (2010)
*
Version 2 (2011)
*
Version 3 (2012) - Latest release
* Version 4 (2013) - You are here
Test Pages:Test pages are available for their respective versions in each of the previous topics (links above).
Version 2's thread has the most information and resources since that was the biggest overhaul.
Features:
I'm still calling it beta, so test out these features sometime:
- Preferences for port, debug echos, local IP restriction, timeout in MS, root folder, default index page, and Torquescript tag prefixes and suffixes can be set in the Webserver creation.
- Setting of variables familiar to PHP users such as $_GET, $_POST, and $_SERVER. The $_SERVER variables are dynamically created in Webserver::finish based in on the header received.
- Torquescript located in pages is evaluated before the data is sent to the client, allowing for very dynamic pages such as a real-time score display or even an external server management page.
From a more in depth point of view, it has all this and more:
- Easily editable settings in object creation
- Optional debug echos can be turned on
- Accepts incoming connections on any port
- Can filter to only local IP addresses
- Connections can timeout after a delay
- Lines parsed as received to allow for binary data
- Binary data can be submitted (POST)
- Lines parsed as a whole after all submitted
- Temporary file used for reading binary data
- Sets $_GET based on provided arguments
- Sets $_SERVER based on provided header
- Sets $_POST based on provided body data
- Allows for defaulting to an index page
- Sends a 404 error if page is not found
- Support functions include, print, and puts
- localOnly restriction now checks with isLANAddress
- Cleaned up some of hard coding with Webserver methods
- Client object is deleted after disconnecting
- Improved basetype methods to be more dynamic
- Added version of base64Encode to work with null values
- Added a function to pad a basetype on the left
- WebSockets! And support functions for them!
- Redirect image requests to an external webserver
- Show GUI on demand by converting to HTML and Javascript dynamically
Ok, so it's another year and another time I'm feeling motivated to add a bunch of stuff to my webserver. We last left off last year with the addition of WebSockets, and there was talk of making the server redirect image requests, but that never got done since WebSockets were more important. So I'll add that in this time, as well as this potentially cool thing I've been thinking about for some time now: in-browser GUI!
Basically, there would be functions in place that you would pass a GUI object to, and it would loop through it and its children objects and create an HTML layout representing the GUI. Here is an early picture I took when I was just starting, which includes how little the .tqs pages require in them:
http://i.imgur.com/l6j3d0g.pngWhat are the benefits of this? Well, practically, maybe not a lot. But one thing it can do is deliver GUI to the client without them having to download anything. Of course, downloading is always the better option, but in some cases it isn't available, such as the user being unable to install add-ons - which actually happens - or if the gamemode developer wants to be able to update the GUI on the fly without requiring constant updates from the client.
Going with the idea of delivering GUI on demand, I set up a test. When a client joins the server, they would click a link in the welcome message to go to a web page they would leave open in the bacgrkound, so windowed mode is recommended. Then, when a GUI needs to open, the server tells the browser through a WebSocket of a page containing the GUI conversion code, which opens in a pop-up. Here is how it would work, where the browser window is the
client's and the console is the
server's:
http://www.youtube.com/watch?v=U-Mz1nZM2tw&hd=1I post this mainly so I can get your feedback as coders (and so I actually get it done):
- Would you find in-browser GUI to be useful as a gamemode host?
- If you were to utilize this, what features would you need implemented?
- Are there additional features you would like implemented in the webserver?
Last topic had Lugnut contributing some code, so of course feel free to post anything you've edited with the webserver if you want me to include it in the base script. Otherwise don't hesitate to post suggestions/feedback/questions, as this is probably my favorite Torque project and I want it to be as complete as possible.
Thanks.