I was thinking some thing along those lines, but I really don't have any idea where to start. To quote Steve Jobs, "Everything out there right now is shit." at least in PHP land. The require some odd choice to get Ratchet PHP to work and I really don't want that.
Anyway, I want to re-factor the PRISM code base so we can get too a point where it can be used with any protocol not just LFS connections from InSim, but also HTTP connections (already supported, thanks Vic), and Telnet connections (already supported, thanks Vic). I want to add WebSockets too that stack, and have all of these programs communicate through the PRISM.
Basically, the PSR-0 patch from T3 and Co would become the base for it, and we'd move all of the LFS / InSim stuff into the $PRISM/modules/lfs/ folder, and all of the HTTP, Telnet stuff into $PRISM/modules/HTTP & $PRISM/modules/Telnet. The last part would be the $PRISM/modules/WebSockets, that _might_ require the HTTP module to work, as it's an upgrade request.
From here plugins would be allowed to communicate on any protocol there was a module for. So you could have a plugin that would use the WebSocket connections and the LFS connection modules.
Note: Importing rules are per file basis, meaning included files will NOT inherit the parent file's importing rules.
<?php
use modules\lfs\insim;
use modules\websockets;
class Multiplexing
{
const URL = 'http://lfsforum.net/forumdisplay.php?f=312';
const NAME = 'Multiplexing Example';
const AUTHOR = 'PRISM Dev Team';
const VERSION = PHPInSimMod::VERSION;
const DESCRIPTION = 'WebSockets and LFS InSim Connections Multiplexing';
public function __construct()
{
$this->registerPacket('onNewPlayer', ISP::NPL);
$this->registerPacket('onPlayerLeave', ISP::PLL);
}
public function onNewPlayer(ISP_NPL $NPL)
{
$this->webSocket(json_encode($NPL));
}
public function onPlayerLeave(ISP_PLL $PLL)
{
$this->webSocket(json_encode($PLL));
}
}
?>
I honestly, don't even know where to start with that one. Because, I should really allow for multiple WebSocket connections. But I guess, that would be handled like multiple InSim connections, where it's agnostic too the plugin, and is a configuration setting.