laravel-websockets/src/PubSub/ReplicationInterface.php

89 lines
2.4 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
*/
public function publish(string $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
*/
public function subscribe(string $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
*/
public function unsubscribe(string $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
*/
public function joinChannel(string $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
*/
public function leaveChannel(string $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
*/
public function channelMembers(string $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
*/
public function channelMemberCounts(string $appId, array $channelNames): PromiseInterface;
}