-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMessageHandlerInterface.php
60 lines (53 loc) · 1.65 KB
/
MessageHandlerInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* This file is a part of Woketo package.
*
* (c) Nekland <[email protected]>
*
* For the full license, take a look to the LICENSE file
* on the root directory of this project
*/
namespace Nekland\Woketo\Message;
use Nekland\Woketo\Core\AbstractConnection;
use Nekland\Woketo\Exception\WebsocketException;
/**
* Interface MessageHandlerInterface
*
* If there is only one message handler object (that *you* instantiate) you can guess what is the current client using the spl hash of the connection.
*/
interface MessageHandlerInterface
{
/**
* Is called when a new connection is established.
*
* @param AbstractConnection $connection
*/
public function onConnection(AbstractConnection $connection);
/**
* Is called on new text data.
*
* @param string $data Text data
* @param AbstractConnection $connection
*/
public function onMessage(string $data, AbstractConnection $connection);
/**
* Is called on new binary data.
*
* @param string $data Binary data
* @param AbstractConnection $connection
*/
public function onBinary(string $data, AbstractConnection $connection);
/**
* This callback is call when there is an error on the websocket protocol communication.
*
* @param WebsocketException $e
* @param AbstractConnection $connection
*/
public function onError(WebsocketException $e, AbstractConnection $connection);
/**
* Is called when the connection is closed by the client
*
* @param AbstractConnection $connection
*/
public function onDisconnect(AbstractConnection $connection);
}