2019-03-25 22:00:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace BeyondCode\LaravelWebSockets\PubSub;
|
|
|
|
|
|
|
|
|
|
use stdClass;
|
|
|
|
|
use React\EventLoop\LoopInterface;
|
|
|
|
|
|
|
|
|
|
interface ReplicationInterface
|
|
|
|
|
{
|
|
|
|
|
/**
|
2019-03-25 22:37:14 +00:00
|
|
|
* Boot the pub/sub provider (open connections, initial subscriptions, etc).
|
2019-03-25 22:00:54 +00:00
|
|
|
*
|
|
|
|
|
* @param LoopInterface $loop
|
|
|
|
|
* @return self
|
|
|
|
|
*/
|
|
|
|
|
public function boot(LoopInterface $loop): self;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-03-25 22:37:14 +00:00
|
|
|
* Publish a payload on a specific channel, for a specific app.
|
2019-03-25 22:00:54 +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.
|
2019-03-25 22:00:54 +00:00
|
|
|
*
|
|
|
|
|
* @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.
|
2019-03-25 22:00:54 +00:00
|
|
|
*
|
|
|
|
|
* @param string $channel
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function unsubscribe(string $appId, string $channel): bool;
|
|
|
|
|
}
|