-
Notifications
You must be signed in to change notification settings - Fork 1
/
PortInterface.php
134 lines (113 loc) · 2.82 KB
/
PortInterface.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/*
* This file is part of the phpflo/phpflo package.
*
* (c) Marc Aschmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace PhpFlo\Common;
use PhpFlo\Common\Exception\InvalidDefinitionException;
use PhpFlo\Common\Exception\InvalidTypeException;
use PhpFlo\Common\Exception\PortException;
use PhpFlo\Common\Exception\SocketException;
/**
* Interface PortInterface
*
* @package PhpFlo\Common
* @author Marc Aschmann <[email protected]>
*/
interface PortInterface
{
/**
* @param SocketInterface $socket
*/
public function onConnect(SocketInterface $socket);
/**
* @param SocketInterface $socket
*/
public function onDisconnect(SocketInterface $socket);
/**
* @return array
*/
public function getAttributes(): array ;
/**
* @param string $name
* @return mixed|null
*/
public function getAttribute(string $name);
/**
* @return string
*/
public function getName(): string;
/**
* @param SocketInterface $socket
* @throws InvalidDefinitionException
* @return PortInterface
*/
public function attach(SocketInterface $socket): PortInterface;
/**
* @param mixed $data
* @param SocketInterface $socket
*/
public function onData($data, SocketInterface $socket);
/**
* @param string $groupName
* @param SocketInterface $socket
*/
public function onBeginGroup(string $groupName, SocketInterface $socket);
/**
* @param string $groupName
* @param SocketInterface $socket
*/
public function onEndGroup(string $groupName, SocketInterface $socket);
/**
* Callback for shutdown event, disconnects and detaches port and sockets.
*/
public function onShutdown();
/**
* Callback for detach event.
*/
public function onDetach();
/**
* @throws SocketException
*/
public function connect();
/**
* Emits disconnect event.
*/
public function disconnect();
/**
* @return bool
*/
public function isConnected(): bool;
/**
* Checks if port is attached.
*
* @return bool
*/
public function isAttached(): bool;
/**
* @param string $groupName
* @throws PortException
*/
public function endGroup(string $groupName);
/**
* @param mixed $data
* @return mixed|null
* @throws InvalidTypeException
*/
public function send($data);
/**
* @param SocketInterface $socket
*/
public function detach(SocketInterface $socket);
/**
* @param string $groupName
* @return null
* @throws PortException
*/
public function beginGroup(string $groupName);
}