Facades

There are some facades you can use in your Laravel Application:

  • SwooleTW\Http\Server\Facades\Server: Swoole server instance, you will rarely need this class unless you're familiar with Swoole server. You can get current server info by the following:
  1. $data = Server::stats();
  2.  
  3. // response data
  4. array(8) {
  5. // the launched time of Swoole server
  6. ["start_time"]=>
  7. int(1525352666)
  8. // the number of current connections
  9. ["connection_num"]=>
  10. int(1)
  11. // the number of connections accepted
  12. ["accept_count"]=>
  13. int(1)
  14. // the number of connections closed
  15. ["close_count"]=>
  16. int(0)
  17. // the number of task which is queuing up
  18. ["tasking_num"]=>
  19. int(0)
  20. // the number of request received
  21. ["request_count"]=>
  22. int(0)
  23. // the number of request received by the current worker
  24. ["worker_request_count"]=>
  25. int(0)
  26. // current coroutine number
  27. ["coroutine_num"]=>
  28. int(1)
  29. }

Get more detail at: https://www.swoole.co.uk/docs/modules/swoole-server-methods

  • SwooleTW\Http\Table\Facades\SwooleTable: A wrapper class for your customized Swoole tables.
  1. // get a table by table name
  2. $table = SwooleTable::get('table_name');
  3. // or you can also call like this
  4. $table = SwooleTable::table_name;
  5.  
  6. // get all registered tables
  7. $tables = SwooleTable::getAll();
  • SwooleTW\Http\Websocket\Facades\Websocket: Websocket class provided by this package.

  • SwooleTW\Http\Websocket\Facades\Room: You can get some room infos by this class.

  1. // get all fds by a room name
  2. $fds = Room::getClients('room_name');
  3.  
  4. // get joint rooms by a fd
  5. $rooms = Room::getRooms(1);