JAXLLoop::unwatch PHP Méthode

unwatch() public static méthode

public static unwatch ( $fd, $opts )
    public static function unwatch($fd, $opts)
    {
        if (isset($opts['read'])) {
            $fdid = (int) $fd;
            if (isset(self::$read_fds[$fdid])) {
                unset(self::$read_fds[$fdid]);
                unset(self::$read_cbs[$fdid]);
                --self::$active_read_fds;
            }
        }
        if (isset($opts['write'])) {
            $fdid = (int) $fd;
            if (isset(self::$write_fds[$fdid])) {
                unset(self::$write_fds[$fdid]);
                unset(self::$write_cbs[$fdid]);
                --self::$active_write_fds;
            }
        }
        JAXLLogger::debug("Unwatch: active read fds: " . self::$active_read_fds . ", write fds: " . self::$active_write_fds);
    }

Usage Example

 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)."");
 }
All Usage Examples Of JAXLLoop::unwatch