Recently I have been working on a small example game for my friend Alex. The game is a version of traditional PONG, two bats and a ball. The difference between my PONG and other PONG’s, is that it’s played on two phones, each player uses their own phone, one player could be in Bangkok and the other in Stockholm, anyway, here’s what happened.
Step 1 – Writing the pong game, this went very well, I had it working in about 2 hours, scores and all. (If your reading this Nolan, I won’t sell the game and I promise, I’ll buy you a beer:)
Step 2 – I had already written an IRC class in MoSync, I’d noticed that IRC was essentially bomb proof and pretty quick. So I implemented the multi-player part of the game, using (don’t laugh) IRC. This worked pretty well, the only problem was flow control, sometimes you get 20 messages a second, other times nothing for a second, then 40 messages.
Step 3 – So I decided to write my own server. I based this on a java server I wrote in 1998, there were some horrific deprecation problems, so I thought I’d try a few other routes.
Step 4 – I wrote a server from scratch in C, this was even more troublesome that Java, I just hate the socket/communications API’s in C, they are just horrible mystical bits of unreadability.
Step 5 – I went back to Java, started at 6am one morning and was finished by 12am, so the moral is, I should have just stuck with step 2 and fixed my deprecated code.
The Point
Finally I had a server that was:
1. Quick.
2. Multi-channel (like IRC but binary)
3. Could handle vast amounts of connection over many channels simultaneously.
4. It’s simple just a 10k jar file (and growing).
5. It’s easy to run on any computer, regardless of OS.
6. It can be used in conjunction with the JavaScript web sockets API.
7. Its thoroughly generic and multipurpose.
Conclusion
There are so many instances where people create servers, just to connect two (or more) devices together, who would have thought this could be such a problem. Most people will write their own cloud service service, when it really isn’t necessary, all because there isn’t a simple generic server that does just that. So GenServ was born.
Being something of an open source advocate, I fully intend to solve this problem by releasing my server in the next few weeks.
If you would like to help me out write writing some example code or have opinions about my server just comment or drop me a mail.
P.S. IRC can be a good way for devices to communicate, so long as latency and flow control aren’t a problem.
Remy Sharp has written a great blog article, where you can find more info about cross-browser communications methods:
http://html5doctor.com/methods-of-communication/
