Skip to content

Commit

Permalink
tick timer since PR not merged
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gymadarasz authored Apr 10, 2018
1 parent 0423f39 commit e890bcc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/WebSocketServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ abstract class WebSocketServer {
protected $headerOriginRequired = false;
protected $headerSecWebSocketProtocolRequired = false;
protected $headerSecWebSocketExtensionsRequired = false;

// ability to set tick() call timer in the child class
protected $tv_sec = 1;
protected $tv_usec = 0;

function __construct($addr, $port, $bufferLength = 2048) {
$this->maxBufferSize = $bufferLength;
Expand Down Expand Up @@ -88,7 +92,7 @@ public function run() {
$write = $except = null;
$this->_tick();
$this->tick();
@socket_select($read,$write,$except,1);
@socket_select($read,$write,$except, $this->tv_sec, $this->tv_usec);
foreach ($read as $socket) {
if ($socket == $this->master) {
$client = socket_accept($socket);
Expand Down

0 comments on commit e890bcc

Please sign in to comment.