public static function getInstance()
{
if (!self::$instance) {
self::$instance = new WebSocketServer();
}
return self::$instance;
}
/** * Called when the worker is ready to go. * @return void */ public function onReady() { $appInstance = $this; // a reference to this application instance for ExampleWebSocketRoute // URI /exampleApp should be handled by ExampleWebSocketRoute WebSocketServer::getInstance()->addRoute('exampleApp', function ($client) use($appInstance) { return new ExampleWebSocketRoute($client, $appInstance); }); }