Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

8. Facades

Albert Chen edited this page May 3, 2018 · 3 revisions

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:
$data = Server::stats();

// response data
array(8) {
  // the launched time of Swoole server
  ["start_time"]=>
  int(1525352666)
  // the number of current connections 
  ["connection_num"]=>
  int(1)
  // the number of connections accepted
  ["accept_count"]=>
  int(1)
  // the number of connections closed
  ["close_count"]=>
  int(0)
  // the number of task which is queuing up
  ["tasking_num"]=>
  int(0)
  // the number of request received
  ["request_count"]=>
  int(0)
  // the number of request received by the current worker
  ["worker_request_count"]=>
  int(0)
  // current coroutine number
  ["coroutine_num"]=>
  int(1)
}

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.
// get a table by table name
$table = SwooleTable::get('table_name');
// or you can also call like this
$table = SwooleTable::table_name;

// get all registered tables
$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.

// get all fds by a room name
$fds = Room::getClients('room_name');

// get joint rooms by a fd
$rooms = Room::getRooms(1);
Clone this wiki locally