laravel-websockets/src/PubSub/ReplicationInterface.php

89 lines
2.3 KiB
PHP
Raw Normal View History

<?php
namespace BeyondCode\LaravelWebSockets\PubSub;
use React\EventLoop\LoopInterface;
use React\Promise\PromiseInterface;
2020-08-13 11:02:58 +00:00
use stdClass;
interface ReplicationInterface
{
/**
2019-03-25 22:37:14 +00:00
* Boot the pub/sub provider (open connections, initial subscriptions, etc).
*
2020-08-14 05:42:17 +00:00
* @param LoopInterface $loop
2020-08-14 12:35:36 +00:00
* @param string|null $factoryClass
* @return self
*/
2020-08-14 12:35:36 +00:00
public function boot(LoopInterface $loop, $factoryClass = null): self;
/**
2019-03-25 22:37:14 +00:00
* Publish a payload on a specific channel, for a specific app.
*
2020-08-14 05:42:17 +00:00
* @param string $appId
* @param string $channel
* @param stdClass $payload
* @return bool
*/
2020-08-18 17:21:22 +00:00
public function publish($appId, string $channel, stdClass $payload): bool;
/**
2019-03-25 22:37:14 +00:00
* Subscribe to receive messages for a channel.
*
2020-08-14 05:42:17 +00:00
* @param string $appId
* @param string $channel
* @return bool
*/
2020-08-18 17:21:22 +00:00
public function subscribe($appId, string $channel): bool;
/**
2019-03-25 22:37:14 +00:00
* Unsubscribe from a channel.
*
2020-08-14 05:42:17 +00:00
* @param string $appId
* @param string $channel
* @return bool
*/
2020-08-18 17:21:22 +00:00
public function unsubscribe($appId, string $channel): bool;
/**
* Add a member to a channel. To be called when they have
* subscribed to the channel.
*
2020-08-14 05:42:17 +00:00
* @param string $appId
* @param string $channel
* @param string $socketId
* @param string $data
* @return void
*/
2020-08-18 17:21:22 +00:00
public function joinChannel($appId, string $channel, string $socketId, string $data);
/**
* Remove a member from the channel. To be called when they have
* unsubscribed from the channel.
*
2020-08-14 05:42:17 +00:00
* @param string $appId
* @param string $channel
* @param string $socketId
* @return void
*/
2020-08-18 17:21:22 +00:00
public function leaveChannel($appId, string $channel, string $socketId);
/**
* Retrieve the full information about the members in a presence channel.
*
2020-08-14 05:42:17 +00:00
* @param string $appId
* @param string $channel
* @return PromiseInterface
*/
2020-08-18 17:21:22 +00:00
public function channelMembers($appId, string $channel): PromiseInterface;
/**
* Get the amount of users subscribed for each presence channel.
*
2020-08-14 05:42:17 +00:00
* @param string $appId
* @param array $channelNames
* @return PromiseInterface
*/
2020-08-18 17:21:22 +00:00
public function channelMemberCounts($appId, array $channelNames): PromiseInterface;
}