ThreadSpace: Hyperbol Server List
by Nickolas on Dec.22, 2009, under Laboratory
I already talked about that little thing once, without much explanation on what it does. So I’ll get more into it right away.
What is ThreadSpace: Hyperbol?
Well, that is a game I used to play. I was playing this game as “Hyrkali”, and I was getting quite good at it. The goal is simple: destroy or get destroyed (if JackD is playing, it is more like “get pwned” then anything else…
). You control a ship that is highly customizable and you can battle on different arena with different objectives, with team or not.
Instead of explaining everything, I’d rather let the developers do it. See http://www.hyperbol.com/ for more information.
So why such a tool?
I developed this tool in order to have an efficient means to see if there was anyone playing, on what server and so on. The original idea was from Nephyrin, who built a Proof Of Concept (PoC) for XML and XLST, a style sheet.
The script was working well, but wasn’t user-friendly at all.
So I built the first version of the script, which was simply parsing the XML Nephyrin generated. That worked wonders, until his XML generator stopped working. It was probably shut down by him, I never knew what happened there. The thing I knew is that my list was no longer usable.
That’s when I decided to build my own XML Generator. To do so, I had to know more about socket communication, since the generator had to connect with the game Master Server. This is where Vek, one of the game developer helped a lot. He essentially built the whole XML Generator from scratch, puting all that into a simple Python script.
I only had to call the python script to generate my own fresh XML. Voilà, the list was now back on the web.
The script
The script is pretty straightforward: the PHP calls (exec) for the Python script, which generate the XML. Once the XML is generated, the PHP goes on with the parsing of it, the creation of the output and the output itself.
One thing that can be done is put the Python script in a Cron job so it runs all by itself every once in a while. Since I cannot define cron job in interval less then 15 minutes, I used the solution I just named, the PHP exec() method.
One could also run the Python script right from his computer (you’d need a Python Parser installed on your computer) and let it run in a loop, uploading the XML on a FTP server.
Since the code is already all on GitHub, I won’t copy it again. I’ll explain how I built the server list page instead (since the “index.php” isn’t in the GitHub repository).
The HTML
After the simple layout, I display the output from the XML this way:
<script>
var refreshId = setInterval(function()
{
$('#refresh_zone').fadeOut("slow").load('ajax_refresh.php').fadeIn("slow");
}, 60000);
//60 x 1000 = 1 minute (60000)
$(document).ready(function()
{
$('#refresh_zone').load('ajax_refresh.php');
});
</script>
Yes, that is jQuery script… Why I used that, instead of the usual MooTools? Because I used another jQuery script named yShout5 to get a Chat-Like area on my page. Since it requires jQuery, I did my Ajax refresh using the same framework.
Since this post isn’t a yShout5 usage tutorial, I won’t get into explaining how it works… you can always go see the Demo itself for that.
Conclusion
That pretty much sums it all up.
I want to thanks Nephyrin for the idea, and Vek for his awesome support with the XML generation part.
I may develop more on that tool later, I’d really like to have a PHP version of the XML generator. I don’t know if I’ll ever have time for that, since there is a working script online already, developing it is kinda like overkill… but I’ll see what can be done.


January 14th, 2010 on 16:30
I stumbled upon your blog by accident. Pretty informative post.
January 21st, 2010 on 10:54
Thanks you Lucille.
I hope to have some time on my hands in order to put more stuff out there, but client’s website takes priority in my schedule!