1 | <?php |
||
25 | class MessageProcessor |
||
26 | { |
||
27 | /** |
||
28 | * @var FrameFactory |
||
29 | */ |
||
30 | private $frameFactory; |
||
31 | |||
32 | /** |
||
33 | * @var Rfc6455MessageHandlerInterface[] |
||
34 | */ |
||
35 | private $handlers; |
||
36 | |||
37 | public function __construct(FrameFactory $factory = null) |
||
42 | |||
43 | /** |
||
44 | * @param string $data |
||
45 | * @param ConnectionInterface $socket |
||
46 | * @param Message|null $message |
||
47 | * @return \Generator |
||
48 | */ |
||
49 | public function onData(string $data, ConnectionInterface $socket, Message $message = null) |
||
80 | |||
81 | /** |
||
82 | * @param Rfc6455MessageHandlerInterface $handler |
||
83 | * @return self |
||
84 | */ |
||
85 | public function addHandler(Rfc6455MessageHandlerInterface $handler) |
||
91 | |||
92 | /** |
||
93 | * @param Frame|string $frame |
||
94 | * @param ConnectionInterface $socket |
||
95 | * @param int $opCode An int representing binary or text data (const of Frame class) |
||
96 | */ |
||
97 | public function write($frame, ConnectionInterface $socket, int $opCode = Frame::OP_TEXT) |
||
108 | |||
109 | /** |
||
110 | * @return FrameFactory |
||
111 | */ |
||
112 | public function getFrameFactory(): FrameFactory |
||
116 | |||
117 | /** |
||
118 | * @param ConnectionInterface $socket |
||
119 | */ |
||
120 | public function timeout(ConnectionInterface $socket) |
||
125 | |||
126 | /** |
||
127 | * @param ConnectionInterface $socket |
||
128 | */ |
||
129 | public function close(ConnectionInterface $socket) |
||
133 | } |
||
134 |