Making a SSE/Server-sent Events server "framework"
Wednesday, February 28, 2007 9:59:13 PM
The basic idea was to have something on top of which I could build more "services" later on.
I posted the whole source code of the "SSE framework" I wrote in Python to my old blog.
Now the code linked there probably contains a bug or two which I later fixed. And I'm actually still adding new features to the base framework.
This one is probably my only code base that I'm still adding new features to after leaving it alone for this long. Often times I find myself scrapping old code and writing it from scratch again, but not this time. I guess the code it just so clean... and I really like Python, too.
This base framework/server was/is used in numerous projects: IRC Listener, MegaHAL Chat, "WarGames" - a now scrapped idea for a Defcon style game, a server-side controlled physics demonstration, Opera Command network play beta and TankWar Online... Maybe some others too which I forgot.
I've recently been checking on TankWar a bit and it seems a bunch of school kids from USA have been using it to chat a lot. Now, that in itself is just fine by me, but the fact that they can't even behave properly is not.
Because of this, I decided it's time to add new admin console powers. I already had some basic commands you could do from the console but they were rather limited: Get a list of all services + their client counts and send messages to the services. I needed a command for removing clients too.
It needed only a bit of tweaking to the old console command code which pretty much just checked if the command started with /list or a name of a service to decide whether to give a list of services or send a message. I just changed the function so that it would call parseAdminCommand function on the service the command was sent to. Because the system is class-based it's easy to add new features to the parseAdminCommand function, just like the old parse command for parsing GET requests. It only requires one to override the base class' function in a derived class to add more functionality.
I love OOP.

It seems there still isn't any other SSE "frameworks" available on the 'net on which you could build your own services. I've updated the source code for the framework which you can get from http://admins.fi/~eagleeye/python/sseframework.py
Also, an example service source code can be found from http://admins.fi/~eagleeye/python/sseexample.py
There are some details on usage on this blogpost in my old blog (the same as mentioned earlier)







How to use Quote function: