unwatch() public static method

public static unwatch ( $fd, $opts )
 public function on_write_ready($fd)
 {
     //_debug("on write ready called");
     $total = strlen($this->obuffer);
     $bytes = @fwrite($fd, $this->obuffer);
     $this->send_bytes += $bytes;
     _debug("sent " . $bytes . "/" . $this->send_bytes . " of data");
     _debug(substr($this->obuffer, 0, $bytes));
     $this->obuffer = substr($this->obuffer, $bytes, $total - $bytes);
     // unwatch for write if obuffer is empty
     if (strlen($this->obuffer) === 0) {
         JAXLLoop::unwatch($fd, array('write' => true));
         $this->writing = false;
     }
     //_debug("current obuffer size: ".strlen($this->obuffer)."");
 }
Beispiel #2
0
 protected function del_write_cb($client_id)
 {
     if (!$this->clients[$client_id]['writing']) {
         return;
     }
     JAXLLoop::unwatch($this->clients[$client_id]['fd'], array('write' => true));
     $this->clients[$client_id]['writing'] = false;
 }
Beispiel #3
0
 public function stop()
 {
     JAXLLoop::unwatch($this->in, array('read' => true));
 }
Beispiel #4
0
function manager_read()
{
    global $astman;
    $response = $astman->wait_response(true);
    $reconnects = $astman->reconnects;
    $oldsocket = $astman->socket;
    while ($response === false && $reconnects > 0) {
        $astman->disconnect();
        if ($astman->connect($astman->server . ':' . $astman->port, $astman->username, $astman->secret, $astman->events) !== false) {
            JAXLLoop::watch($astman->socket, array('read' => 'manager_read'));
            JAXLLoop::unwatch($oldsocket, array('read' => true));
            $response = true;
        } else {
            if ($reconnects > 1) {
                $astman->log("reconnect command failed, sleeping before next attempt");
                sleep(1);
            } else {
                $astman->log("FATAL: no reconnect attempts left, command permanently failed");
                exit;
            }
        }
        $reconnects--;
    }
}