Пример #1
0
 function ev_error($buffer, $error, $id)
 {
     event_buffer_disable(self::$buffers[$id], EV_READ | EV_WRITE);
     event_buffer_free(self::$buffers[$id]);
     fclose(self::$connections[$id]);
     unset(self::$buffers[$id], self::$connections[$id]);
 }
Пример #2
0
function ev_error($buffer, $error, $id)
{
    event_buffer_disable($GLOBALS['buffers'][$id], EV_READ | EV_WRITE);
    event_buffer_free($GLOBALS['buffers'][$id]);
    fclose($GLOBALS['connections'][$id]);
    unset($GLOBALS['buffers'][$id], $GLOBALS['connections'][$id]);
}
Пример #3
0
 protected function Close($id)
 {
     event_buffer_disable($this->buffers[$id], EV_READ | EV_WRITE);
     event_buffer_free($this->buffers[$id]);
     fclose($this->connections[$id]);
     unset($this->buffers[$id], $this->connections[$id]);
     $this->onClose($id);
 }
 function ev_error($buffer, $error, $id)
 {
     $this->send_to_all(json_encode(array('type' => 'closed', 'id' => $id)));
     event_buffer_disable(self::$buffers[$id], EV_READ | EV_WRITE);
     event_buffer_free(self::$buffers[$id]);
     fclose(self::$connections[$id]);
     unset(self::$buffers[$id], self::$connections[$id], self::$users[$id]);
 }
Пример #5
0
 /**
  * Free from loop
  */
 public function __destruct()
 {
     if (!empty($this->event)) {
         event_buffer_disable($this->event, EV_READ | EV_WRITE);
         event_buffer_free($this->event);
         unset($this->stream, $this->event);
     }
 }
Пример #6
0
 /**
  * Disables buffered event
  *
  * @see event_buffer_disable
  *
  * @throws EventException|\InvalidArgumentException
  *
  * @param int $events Any combination of EV_READ and EV_WRITE.
  *
  * @return EventBuffer
  */
 public function disable($events = null)
 {
     if (null === $events) {
         throw new \InvalidArgumentException('Events to disable must be specified for.
                 Any combination of EV_READ and EV_WRITE (event_buffer_disable).');
     }
     if (!event_buffer_disable($this->resource, $events)) {
         throw $this->exception('Could not disable buffered event (event_buffer_disable).');
     }
     return $this;
 }
Пример #7
0
 public function disconnectClient($id)
 {
     $this->log("disconnectClient({$id})");
     $client = $this->clients[$id];
     if (!$client['request']->fired('end')) {
         $client['request']->fire('end');
     }
     if (!$client['disconnect'] && !$client['request']->fired('close')) {
         $client['request']->fire('close', $id);
     }
     ///
     $this->clients[$id]['response']->connection = null;
     $this->clients[$id]['response']->ev_buffer = null;
     ///
     stream_socket_shutdown($client['socket'], STREAM_SHUT_RDWR);
     event_buffer_disable($client['buffer'], EV_READ | EV_WRITE);
     event_buffer_free($client['buffer']);
     unset($this->clients[$id]);
 }
 protected function freeBuffer($conn_num)
 {
     event_buffer_disable($this->connection_buffers[$conn_num], EV_READ | EV_WRITE);
     event_buffer_free($this->connection_buffers[$conn_num]);
     unset($this->connection_buffers[$conn_num]);
     self::log('Connection', $conn_num, 'buffer is free. Fly, bird, fly!');
 }
 protected function close($connectionId)
 {
     fclose($this->getConnectionById($connectionId));
     if (isset($this->clients[$connectionId])) {
         unset($this->clients[$connectionId]);
     } elseif (isset($this->_services[$connectionId])) {
         unset($this->_services[$connectionId]);
         if (!$this->_services) {
             exit;
         }
     } elseif ($this->getConnectionById($connectionId) == $this->_server) {
         /*unset($this->_server);
           event_del($this->event);
           event_free($this->event);
           exit();*/
     }
     unset($this->_write[$connectionId]);
     unset($this->_read[$connectionId]);
     event_buffer_disable($this->buffers[$connectionId], EV_READ | EV_WRITE);
     event_buffer_free($this->buffers[$connectionId]);
     unset($this->buffers[$connectionId]);
 }
Пример #10
0
 protected function close($connectionId)
 {
     @fclose($this->getConnectionById($connectionId));
     event_buffer_disable($this->buffers[$connectionId], EV_READ | EV_WRITE | EV_PERSIST);
     event_buffer_free($this->buffers[$connectionId]);
     unset($this->buffers[$connectionId]);
 }
 /**
  * Zamkniecie polaczenia
  * @return boolean                         czy zamknieto polaczenie
  */
 public function close()
 {
     if (is_resource($this->eventBuffer) and 'buffer event' == get_resource_type($this->eventBuffer)) {
         event_buffer_disable($this->eventBuffer, EV_READ | EV_WRITE);
         event_buffer_free($this->eventBuffer);
     }
     if (is_resource($this->sock)) {
         fclose($this->sock);
     }
     return true;
 }
Пример #12
0
 public function read_request($event, $length)
 {
     $request_message = event_buffer_read($this->offer_event, $length);
     event_buffer_disable($this->offer_event, EV_READ | EV_WRITE);
     event_buffer_free($this->offer_event);
     unset($this->offer_event);
     socket_shutdown($this->offer_socket);
     socket_close($this->offer_socket);
     unset($this->offer_socket);
     $this->become_intern($request_message);
 }
Пример #13
0
 /**
  * 删除某个fd的所有事件
  * @see BaseEvent::delAll()
  */
 public function delAll($fd)
 {
     $event_key = (int) $fd;
     if (!empty($this->allEvents[$event_key])) {
         foreach ($this->allEvents[$event_key] as $flag => $event) {
             event_del($event);
         }
     }
     if (isset($this->eventBuffer[$event_key])) {
         event_buffer_disable($this->eventBuffer[$event_key], EV_READ | EV_WRITE);
         event_buffer_free($this->eventBuffer[$event_key]);
     }
     unset($this->allEvents[$event_key], $this->eventBuffer[$event_key]);
     return true;
 }
Пример #14
0
function ev_write($buffer, $id)
{
    global $clients;
    // close if the client is on the kill list
    if (!empty($clients[$id]['kill_time'])) {
        event_buffer_disable($clients[$id]['ev_buffer'], EV_READ | EV_WRITE);
        event_buffer_free($clients[$id]['ev_buffer']);
        fclose($clients[$id]['socket']);
        unset($clients[$id]);
    }
}
Пример #15
0
 function _closeConnections()
 {
     if (APP_DEBUG === true) {
         Log::write('eSeal offline. 电子铅封退出。', Log::INFO);
     }
     foreach (self::$buffers as $key => $buf) {
         event_buffer_disable($buf, EV_READ | EV_WRITE);
         event_buffer_free($buf);
         unset(self::$buffers[$key]);
     }
     foreach (self::$connections as $key => $conn) {
         fclose($conn);
         unset(self::$connections[$key]);
     }
     event_base_loopexit(self::$base);
     event_base_free(self::$base);
     fclose(self::$socket_server);
 }
 protected function close($connectionId)
 {
     fclose($this->getConnectionById($connectionId));
     if (isset($this->clients[$connectionId])) {
         unset($this->clients[$connectionId]);
     } elseif (isset($this->services[$connectionId])) {
         unset($this->services[$connectionId]);
     } elseif ($this->getIdByConnection($this->_server) == $connectionId) {
         unset($this->_server);
         /*event_del($this->event);
           event_free($this->event);
           unset($this->event);*/
     } elseif ($this->getIdByConnection($this->_service) == $connectionId) {
         unset($this->_service);
         /*event_del($this->service_event);
           event_free($this->service_event);
           unset($this->service_event);*/
     } elseif ($this->getIdByConnection($this->_master) == $connectionId) {
         unset($this->_master);
     }
     unset($this->_write[$connectionId]);
     unset($this->_read[$connectionId]);
     event_buffer_disable($this->buffers[$connectionId], EV_READ | EV_WRITE | EV_PERSIST);
     event_buffer_free($this->buffers[$connectionId]);
     unset($this->buffers[$connectionId]);
 }
Пример #17
0
 public function removeClient(Client $client)
 {
     if ($this->disconnect_callback) {
         call_user_func_array($this->disconnect_callback, [$client]);
     }
     $buf = $client->getBuffer();
     $conn = $client->getConnection();
     event_buffer_disable($buf, EV_READ | EV_WRITE);
     event_buffer_free($buf);
     fclose($conn);
 }