class GameServer extends SocketServer
{
function on_connect($clientID)
{
$cObj = $this->getClientObject($clientID);
// Sleep for just a sec to allow for the client to finish writing (if it's WebSocket) //
usleep(75000);
//$input = socket_read($this->clients[$i]->socket, 2048, PHP_BINARY_READ);
@socket_recv($this->clients[$i]->socket, $input, 2048, MSG_DONTWAIT);
I wanted to let you know (in addition to posts at TMC, TMS, and Mudlab) about the MUD lib/codebase I just released.
It's written in PHP and supports traditional telnet connections, but what's really cool (I think, anyway) is the native support for WebSockets, built into the HTML 5 specification. This means that clients in web browsers can connect to the game directly without need for Flash or Java, opening up the realm of possibilities for highly mobile, lightweight browser clients.
I've included one such client in the PHudBase package. It currently only functions in Google Chrome (as Chrome's the only one to support the WebSocket), but it does work. After talking with KaVir at TMC, I'm going to begin work today on a specification for implementing WebSocket communication in existing codebases, which would give your players, of course, the option of using a browser-based client (even on mobile devices, eventually).
The project (with a link to the demo) is hosted at http://www.phudbase.com, which links to the Google Code project where the codebase itself can be found.
I've also added it here (currently pending approval), and I'll do my best to keep current releases in the Code Repository.
I hope you folks will give it a try and let me know what you think or even offer some improvements of your own. This code is so far largely untested in live environments, and while I am very confident in its ability to scale, I just don't know how far or what could be done more efficiently in general.
Look forward to your comments!
- John