将fd绑定到uid,uid不能为0.

@param $fd
@param $uid
@param bool $isKick 是否踢掉uid上一个的链接

@throws \Exception
192918
public function bindUid($fd, $uid, $isKick = true)
    {
        if (!is_string($uid) && !is_int($uid)) {
            throw new \Exception('uid必须为string或者int');
        }
        //这里转换成string型的uid，不然ds/Set有bug
        $uid = (string) $uid;
        if ($isKick) {
            $this->kickUid($uid, false);
        }
        $this->uid_fd_table->set($uid, ['fd' => $fd]);
        $this->fd_uid_table->set($fd, ['uid' => $uid]);
        if ($this->isCluster()) {
            ProcessManager::getInstance()->getRpcCall(ClusterProcess::class, true)->my_addUid($uid);
        } else {
            get_instance()->pub('$SYS/uidcount', $this->uid_fd_table->count());
        }
    }
174949
public function setBlameGuids($guids = [], $checkValid = true)
    {
        if (!is_array($guids) || $this->multiBlamesAttribute === false) {
            return null;
        }
        if ($checkValid) {
            $guids = $this->unsetInvalidBlames($guids);
        }
        $multiBlamesAttribute = $this->multiBlamesAttribute;
        $this->$multiBlamesAttribute = Number::composite_guid($guids);
        return $guids;
    }
749846
protected function _loadUids($mailbox, $uids, $uidvalid = null)
    {
        if (!isset($this->_data[$mailbox])) {
            $this->_data[$mailbox] = array();
        }

        $this->_loadMailbox($mailbox, $uidvalid);

        if (empty($uids)) {
            return;
        }

        $ptr = &$this->_data[$mailbox];

        $load = array_flip(
            array_diff_key(
                $this->_getMsgCids(
                    $mailbox,
                    array_unique(array_intersect($this->_mbox[$mailbox]['u']->ids, $uids))
                ),
                $this->_data[$mailbox]
            )
        );

        foreach (array_filter($this->_hash->get(array_keys($load))) as $key => $val) {
            $ptr[$load[$key]] = $val;
        }
    }
114904
final protected function fc($k = null, $d = null) {return dfak(
		/** 2017-12-12 @todo Should we care of a custom `config_path` or not? https://mage2.pro/t/5148 */
		df_config_field($this->getPath())->getData(), $k, $d
	);}
982328
public function podiumEdit($isFirstPost = false)
    {
        $transaction = static::getDb()->beginTransaction();
        try {
            $this->edited = 1;
            $this->touch('edited_at');
            if (!$this->save()) {
                throw new Exception('Post saving error!');
            }
            if ($isFirstPost) {
                $this->thread->name = $this->topic;
                if (!$this->thread->save()) {
                    throw new Exception('Thread saving error!');
                }
            }
            $this->markSeen();
            $this->thread->touch('edited_post_at');

            $transaction->commit();
            Log::info('Post updated', $this->id, __METHOD__);
            return true;
        } catch (Exception $e) {
            $transaction->rollBack();
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
1173279
public function join($fd)
    {
        if($this->handler->joinGroup($this->groupName, $fd))
        {
            RequestContext::getServerBean('FdMap')->joinGroup($fd, $this);
            Event::trigger('IMI.SERVER.GROUP.JOIN', [
                'server'    => RequestContext::getServer(),
                'groupName' => $this->groupName,
                'fd'        => $fd,
            ]);
        }
    }
220695
public function onOpen($fd, Request $request)
    {
        if (! $request->input('sid')) {
            $payload = json_encode(
                [
                    'sid' => base64_encode(uniqid()),
                    'upgrades' => [],
                    'pingInterval' => Config::get('swoole_websocket.ping_interval'),
                    'pingTimeout' => Config::get('swoole_websocket.ping_timeout'),
                ]
            );
            $initPayload = Packet::OPEN . $payload;
            $connectPayload = Packet::MESSAGE . Packet::CONNECT;

            App::make(Server::class)->push($fd, $initPayload);
            App::make(Server::class)->push($fd, $connectPayload);

            return true;
        }

        return false;
    }
293761
private function deleteFilter($uid)
    {
        unset($this->filters[$uid]);
        $this->cache->delete($this->getCacheId($uid));
    }
829898
public function setClientData($uid, $fd, $client_data, $controller_name, $method_name, $params)
    {
        $this->uid = $uid;
        $this->fd = $fd;
        $this->client_data = $client_data;
        if (isset($client_data->rpc_request_id)) {
            $this->isRPC = true;
            $this->rpc_token = $client_data->rpc_token ?? '';
            $this->rpc_request_id = $client_data->rpc_request_id ?? '';
        } else {
            $this->isRPC = false;
        }
        $this->request_type = SwooleMarco::TCP_REQUEST;
        $this->execute($controller_name, $method_name, $params);
    }
958429
public function updateUid($uid, $sid) {
		$sql = 'UPDATE '. self::tableName .' SET uid=:uid WHERE session_id=:session_id';
		
		$params = array(
			'uid'			=> $uid,
			'session_id'	=> $sid
		);
		
		try {
			$retval = $this->db->run_query($sql, $params);
		}
		catch(Exception $e) {
			$this->exception_handler($e->getMessage());
		}
		
		return($retval);
	}
502535
public function commit($xid)
    {
        if ($this->activeTransaction != $xid || $this->activeTransaction === false) {
            return;
        }

        $this->activeTransaction = false;

        if (!$this->connection->commit()) {
            throw new DbException("Commit failed");
        }
    }
127890
public function clientKick($clid, $reasonid = Teamspeak::KICK_CHANNEL, $reasonmsg = null)
    {
        $this->clientListReset();

        $this->execute("clientkick", array("clid" => $clid, "reasonid" => $reasonid, "reasonmsg" => $reasonmsg));
    }
890449
public function guid($guid, $like = false)
    {
        /* @var $this ActiveQuery */
        $model = $this->noInitModel;
        return $this->likeCondition((string)$guid, $model->guidAttribute, $like);
    }
569047
public function setGUID($guid)
    {
        $guidAttribute = $this->guidAttribute;
        if (preg_match(Number::GUID_REGEX, $guid)) {
            $guid = hex2bin(str_replace(['{', '}', '-'], '', $guid));
        }
        return (is_string($guidAttribute) && !empty($guidAttribute)) ? $this->$guidAttribute = $guid : null;
    }
1222073
public function onSwooleClose($serv, $fd)
    {
        parent::onSwooleClose($serv, $fd);
        $uid = $this->getUidFromFd($fd);
        $this->unBindUid($uid, $fd);
    }
115832
public function onReceive(SwServer $server, int $fd, int $fromId, string $data)
    {
        // {{ log
        $this->get('logger')->info('接收数据', [
            'type' => 'TCP',
            'client' => $server->getClientInfo($fd),
            'data' => $data
        ]);
        // }}

        $this->callProtocolMethod('onReceive', $server, $fd, $fromId, $data);
    }
806921
protected function init($data)
    {
        if (! isset($data['id'])) {
            throw new DataSift_Exception_InvalidData('No id found');
        }
        $this->_id = $data['id'];

        if (! isset($data['name'])) {
            throw new DataSift_Exception_InvalidData('No name found');
        }
        $this->_name = $data['name'];

        if (! isset($data['created_at'])) {
            throw new DataSift_Exception_InvalidData('No created_at found');
        }
        $this->_created_at = $data['created_at'];

        if (! isset($data['status'])) {
            throw new DataSift_Exception_InvalidData('No status found');
        }
        $this->_status = $data['status'];

        if (! isset($data['hash_type'], $data)) {
            throw new DataSift_Exception_InvalidData('No hash_type found');
        }
        $this->_hash_type = $data['hash_type'];

        if (! isset($data['hash'])) {
            throw new DataSift_Exception_InvalidData('No hash found');
        }
        $this->_hash = $data['hash'];

        if (! isset($data['last_request'])) {
            $this->_last_request = 0;
        } else {
            $this->_last_request = $data['last_request'];
        }

        if (! isset($data['last_success'])) {
            $this->_last_success = 0;
        } else {
            $this->_last_success = $data['last_success'];
        }

        if (! isset($data['output_type'])) {
            throw new DataSift_Exception_InvalidData('No output_type found');
        }
        $this->_output_type = $data['output_type'];

        if (! isset($data['output_params'])) {
            throw new DataSift_Exception_InvalidData('No output_params found');
        }
        $this->_output_params = $this->parseOutputParams($data['output_params']);
    }