Merge branch 'master' of github.com:beyondcode/laravel-websockets
This commit is contained in:
commit
4c0ee1e3a3
|
|
@ -26,15 +26,15 @@ class Channel
|
||||||
/**
|
/**
|
||||||
* @link https://pusher.com/docs/pusher_protocol#presence-channel-events
|
* @link https://pusher.com/docs/pusher_protocol#presence-channel-events
|
||||||
*
|
*
|
||||||
* @param ConnectionInterface $conn
|
* @param ConnectionInterface $connection
|
||||||
* @param $payload
|
* @param $payload
|
||||||
*/
|
*/
|
||||||
public function subscribe(ConnectionInterface $conn, $payload)
|
public function subscribe(ConnectionInterface $connection, $payload)
|
||||||
{
|
{
|
||||||
$this->saveConnection($conn);
|
$this->saveConnection($connection);
|
||||||
|
|
||||||
// Send the success event
|
// Send the success event
|
||||||
$conn->send(json_encode([
|
$connection->send(json_encode([
|
||||||
'event' => 'pusher_internal:subscription_succeeded',
|
'event' => 'pusher_internal:subscription_succeeded',
|
||||||
'channel' => $this->channelId
|
'channel' => $this->channelId
|
||||||
]));
|
]));
|
||||||
|
|
|
||||||
|
|
@ -11,24 +11,28 @@ class PresenceChannel extends Channel
|
||||||
/**
|
/**
|
||||||
* @link https://pusher.com/docs/pusher_protocol#presence-channel-events
|
* @link https://pusher.com/docs/pusher_protocol#presence-channel-events
|
||||||
*
|
*
|
||||||
* @param ConnectionInterface $conn
|
* @param ConnectionInterface $connection
|
||||||
* @param $payload
|
* @param $payload
|
||||||
*/
|
*/
|
||||||
public function subscribe(ConnectionInterface $conn, $payload)
|
public function subscribe(ConnectionInterface $connection, $payload)
|
||||||
{
|
{
|
||||||
$this->saveConnection($conn);
|
$this->saveConnection($connection);
|
||||||
|
|
||||||
$channelData = json_decode($payload->channel_data);
|
$channelData = json_decode($payload->channel_data);
|
||||||
$this->subscriptions[$channelData->user_id] = $channelData;
|
$this->subscriptions[$channelData->user_id] = $channelData;
|
||||||
|
|
||||||
// Send the success event
|
// Send the success event
|
||||||
$conn->send(json_encode([
|
$connection->send(json_encode([
|
||||||
'event' => 'pusher_internal:subscription_succeeded',
|
'event' => 'pusher_internal:subscription_succeeded',
|
||||||
'channel' => $this->channelId,
|
'channel' => $this->channelId,
|
||||||
'data' => json_encode($this->getChannelData())
|
'data' => json_encode($this->getChannelData())
|
||||||
]));
|
]));
|
||||||
|
|
||||||
//TODO: send member_added message back to client, and broadcast to everyone on channel
|
$this->broadcastToOthers($connection, [
|
||||||
|
'event' => 'pusher_internal:member_added',
|
||||||
|
'channel' => $this->channelId,
|
||||||
|
'data' => json_encode($channelData)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unsubscribe(ConnectionInterface $connection)
|
public function unsubscribe(ConnectionInterface $connection)
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,10 @@
|
||||||
|
|
||||||
namespace BeyondCode\LaravelWebSockets\LaravelEcho\WebSocket;
|
namespace BeyondCode\LaravelWebSockets\LaravelEcho\WebSocket;
|
||||||
|
|
||||||
use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\PusherMessage;
|
|
||||||
use Ratchet\ConnectionInterface;
|
use Ratchet\ConnectionInterface;
|
||||||
use Ratchet\RFC6455\Messaging\MessageInterface;
|
use Ratchet\RFC6455\Messaging\MessageInterface;
|
||||||
use BeyondCode\LaravelWebSockets\WebSocketController;
|
use BeyondCode\LaravelWebSockets\WebSocketController;
|
||||||
use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Channels\ChannelManager;
|
use BeyondCode\LaravelWebSockets\LaravelEcho\Pusher\Channels\ChannelManager;
|
||||||
use stdClass;
|
|
||||||
|
|
||||||
class EchoServer extends WebSocketController
|
class EchoServer extends WebSocketController
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue