WebSocketServer::getInstance PHP Method

getInstance() public static method

public static getInstance ( )
    public static function getInstance()
    {
        if (!self::$instance) {
            self::$instance = new WebSocketServer();
        }
        return self::$instance;
    }

Usage Example

 /**
  * 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);
     });
 }
All Usage Examples Of WebSocketServer::getInstance