62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace NoccyLabs\React\WebSocket;
|
|
|
|
use NoccyLabs\React\WebSocket\Group\ConnectionGroup;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
use React\Http\Message\Response;
|
|
use React\Socket\ConnectionInterface;
|
|
use React\Stream\CompositeStream;
|
|
use React\Stream\ThroughStream;
|
|
|
|
interface WebSocketInterface extends ConnectionInterface
|
|
{
|
|
const EVENT_CONNECT = 'connect';
|
|
const EVENT_CLOSE = 'close';
|
|
const EVENT_GROUP_JOIN = 'join';
|
|
const EVENT_GROUP_LEAVE = 'leave';
|
|
|
|
/**
|
|
* Close the connection with a reason and code.
|
|
*
|
|
* @param string $reason
|
|
* @param int $code
|
|
* @return void
|
|
*/
|
|
public function closeWithReason(string $reason, int $code=1000): void;
|
|
|
|
/**
|
|
* Get the initial HTTP request sent to the server.
|
|
*
|
|
* @return ServerRequestInterface
|
|
*/
|
|
public function getServerRequest(): ServerRequestInterface;
|
|
|
|
/**
|
|
* Assign this connection to a connection group. If the connection is already
|
|
* part of a group, it will leave the current group before joining the new
|
|
* group.
|
|
*
|
|
* @param null|string $name The group name to join
|
|
* @return void
|
|
*/
|
|
public function setGroup(?string $name): void;
|
|
|
|
/**
|
|
* Get the current connection group.
|
|
*
|
|
* @see getGroupName() if you want the name of the group.
|
|
*
|
|
* @return null|ConnectionGroup
|
|
*/
|
|
public function getGroup(): ?ConnectionGroup;
|
|
|
|
/**
|
|
* Get the name of the current connection group
|
|
*
|
|
* @return null|string
|
|
*/
|
|
public function getGroupName(): ?string;
|
|
|
|
}
|