Skip to content

Commit e890bcc

Browse files
authored
tick timer since PR not merged
issue 1: PHP can't find the users.php if includes are in a different folder and it caused a php fatal error (more flexible solution is an autoloader for e.g. composer) issue 2: tick() function called once per seconds but these protected variables able to the extender class to override the tick speed even dynamically See in original PR: ghedipunk#98
1 parent 0423f39 commit e890bcc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/WebSocketServer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ abstract class WebSocketServer {
1717
protected $headerOriginRequired = false;
1818
protected $headerSecWebSocketProtocolRequired = false;
1919
protected $headerSecWebSocketExtensionsRequired = false;
20+
21+
// ability to set tick() call timer in the child class
22+
protected $tv_sec = 1;
23+
protected $tv_usec = 0;
2024

2125
function __construct($addr, $port, $bufferLength = 2048) {
2226
$this->maxBufferSize = $bufferLength;
@@ -88,7 +92,7 @@ public function run() {
8892
$write = $except = null;
8993
$this->_tick();
9094
$this->tick();
91-
@socket_select($read,$write,$except,1);
95+
@socket_select($read,$write,$except, $this->tv_sec, $this->tv_usec);
9296
foreach ($read as $socket) {
9397
if ($socket == $this->master) {
9498
$client = socket_accept($socket);

0 commit comments

Comments
 (0)