morozovsk\websocket\GenericLibevent::onRead PHP Method

onRead() private method

private onRead ( $buffer, $connectionId )
    private function onRead($buffer, $connectionId)
    {
        if (isset($this->services[$connectionId])) {
            if (is_null($this->_read($connectionId))) {
                //connection has been closed or the buffer was overwhelmed
                $this->close($connectionId);
                return;
            } else {
                while ($data = $this->_readFromBuffer($connectionId)) {
                    $this->onServiceMessage($connectionId, $data);
                    //call user handler
                }
            }
        } elseif ($this->getIdByConnection($this->_master) == $connectionId) {
            if (is_null($this->_read($connectionId))) {
                //connection has been closed or the buffer was overwhelmed
                $this->close($connectionId);
                return;
            } else {
                while ($data = $this->_readFromBuffer($connectionId)) {
                    $this->onMasterMessage($data);
                    //call user handler
                }
            }
        } else {
            if (!$this->_read($connectionId)) {
                //connection has been closed or the buffer was overwhelmed
                $this->close($connectionId);
            } else {
                $this->_onMessage($connectionId);
            }
        }
    }