The Gang Garrison 2 Forum

Gang Garrison Discussion => Announcements => Topic started by: MedO on December 13, 2011, 02:24:26 pm

Title: Lobby server source code available
Post by: MedO on December 13, 2011, 02:24:26 pm
This one is only really interesting for programmers. Are you a programmer? No? Then what are you still doing here? Get out!

They gone? Alright. Fellow programmers, you can find the Python source code of our new and improved mod lobby server on Github now, under the ISC license. It's quite messy in overall structure, but hey, I was re-learning Python as I wrote it. Feel free to make it more modular and send back a pull request if you feel so inclined. Or write a statistics module that draws awesome graphs on the status page. Or use the protocol description to add lobby support to your upcoming multiplayer game (you can use the lobby server on our VS - just ask first please. And use a different Lobby ID if it's not related to GG2.)

The repository is here. (https://github.com/Medo42/Faucet-Lobby) This is also where you should report any issues.
Title: Re: Lobby server source code available
Post by: Orpheon on December 13, 2011, 02:57:39 pm
This made my day:
Code: [Select]
                mod = matcher.group(6)
                if(mod=="OHU"):
                    server.infos["game"] = "Orpheon's Hosting Utilities"
                    server.infos["game_short"] = "ohu"
                    server.infos["game_url"] = "http://www.ganggarrison.com/forums/index.php?topic=28839.0"
                else:
                    server.infos["game"] = mod
                    if(len(mod)<=10): del server.infos["game_short"]


Also, I want to follow in case something interesting happens.
Title: Re: Lobby server source code available
Post by: nightcracker on December 14, 2011, 04:43:27 am
Your expirationset class is quite ugly. Here is a better version:

https://gist.github.com/1476083

It's not nice to try and expire the keys whenever possible, by calling (the previously called cleanup_stale) expire_keys all the time (in add, remove, etc). It's more efficient and clear to the user that he/she has to call expirationset.expire_keys() himself, when he/she wants it.

I also removed the use of OrderedDict. If the one found in the repo is the same as the default implementation (collections.OrderedDict), your use also was flawed. It stores the order of ADDING to the dict, not keeping the dict sorted by values (as you assumed, which I found since you use break in your cleanup_stale loop).

So, my version isn't as focused on performance, because I don't think it will be necessary. If it will be necessary you should replace the inner dict with a binary tree.
Title: Re: Lobby server source code available
Post by: MedO on December 14, 2011, 05:11:48 am
I wasn't quite happy with the expirationset myself, will look at your version.

The OrderedDict is required though, it is a backport of the standard OrderedDict to make it available on older versions of Python (like the one we are using on our server). Also, I am aware of which order the entries are stored in. Since the entries are timestamped on insertion, the insertion order is the same as the timestamp order (assuming monotonic time, but even a small clock hitch would just slightly delay the removal of some entries).

Edit: also, longer analysis at the gist.
Title: Re: Lobby server source code available
Post by: nightcracker on December 15, 2011, 02:24:40 am
lso, I am aware of which order the entries are stored in. Since the entries are timestamped on insertion

Oh damn, of course! Well, forget that I said that your usage is flawed, because it obviously isn't.

But I still think using an ordered set is not necessary. Only if you need to call expire_keys VERY often (which I doubt) the performance benefit is non-trivial. Another idea for circumventing the ordered set is storing two dictionaries (values and times) and an index. Every time something gets added it gets added to the expirationset you add the value to the values dict (with the index), and the time to the times dict (with the same index). Then you increment the index.
Title: Re: Lobby server source code available
Post by: Sape on September 21, 2013, 07:27:46 pm
First, sorry for my bad english, second i know the topic is a little old but i want to host my own lobby, i installed Python 2.7 (i try 3.2 also) and when i run for example (in CMD console) Python lobby.py i get this error:

(http://s2.subirimagenes.com/imagen/previo/thump_8629188sin-ttulo.png)

any idea?.. i'm new to this stuff.
Title: Re: Lobby server source code available
Post by: Orpheon on September 28, 2013, 02:39:19 pm
First, sorry for my bad english, second i know the topic is a little old but i want to host my own lobby, i installed Python 2.7 (i try 3.2 also) and when i run for example (in CMD console) Python lobby.py i get this error:

(http://s2.subirimagenes.com/imagen/previo/thump_8629188sin-ttulo.png)

any idea?.. i'm new to this stuff.
You need to install Twisted.
Title: Re: Lobby server source code available
Post by: MedO on September 29, 2013, 07:04:01 am
You can get it from here: http://twistedmatrix.com/trac/ (http://twistedmatrix.com/trac/)
Title: Re: Lobby server source code available
Post by: Sape on October 01, 2013, 06:02:25 pm
Ok, thanks for your help!