• PHP reference
  • Sandbox

Socket

class Sandbox\Socket

Send real time websocket messages.

Example:


$this->socket->send(user(), community(), 'test', ['some' => 'data']);

Front-end Javascript:


scholica.notifications.on('test', function(data){
   alert(JSON.stringify(data));
});

Methods

boolean send(User|integer $user, Community|integer $community, string $type, mixed $payload = [])

Send a real time websocket message to a specific user.

Parameters

  • User|integer $user
  • Community|integer $community
  • string $type
  • mixed $payload

Return Value

  • boolean

boolean broadcast(Community|integer $community, string $type, mixed $payload = [])

Send a real time websocket message to all active users in a community.

Parameters

  • Community|integer $community
  • string $type
  • mixed $payload

Return Value

  • boolean