-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathWebSocketClient.php
More file actions
43 lines (34 loc) · 898 Bytes
/
WebSocketClient.php
File metadata and controls
43 lines (34 loc) · 898 Bytes
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
<?php
namespace ChromeDevtoolsProtocol\WebSocket;
use Wrench\Client;
/**
* @author Jakub Kulhan <jakub.kulhan@gmail.com>
*/
class WebSocketClient extends Client
{
/** @var WebSocketClientSocket */
protected $socket;
protected function configure(array $options)
{
$options = array_merge([
"socket_class" => WebSocketClientSocket::class,
"on_data_callback" => null,
"socket_options" => [],
], $options);
parent::configure($options);
}
public function setDeadline(?\DateTimeImmutable $deadline)
{
$this->socket->setDeadline($deadline);
}
public function receive()
{
// Forward the receive() call to Client::receive()
$payloads = parent::receive();
// If the latest payload(s) are received, clear the buffer. We don't need that copy any more.
if ($payloads)
$this->received = array();
// Return the latest received payloads
return $payloads;
}
}