踢用户下线

@param $uid
@param bool $fromDispatch

@throws \Exception
977317
public function kickUid($uid, $fromDispatch = false)
    {
        if ($this->uid_fd_table->exist($uid)) {//本机处理
            $fd = $this->uid_fd_table->get($uid)['fd'];
            $this->close($fd);
        } else {
            if ($fromDispatch) {
                return;
            }
            if ($this->isCluster()) {
                ProcessManager::getInstance()->getRpcCall(ClusterProcess::class, true)->my_kickUid($uid);
            }
        }
    }
177320
public static function merge($from, $into, ClientInterface $client = null)
    {
        (new static([], $client))
            ->getClient()
            ->setResourcekey(static::class)
            ->send('/v1/customers/merges', 'POST', [
                'from' => $from,
                'into' => $into
            ]);
        return true;
    }
1112559
public function getItemsRaw($limit = null, $offset = null, array $uids = [], array $skipItemIds = [])
    {
        throw new Exception(new Phrase(self::NOT_ENABLED_ERROR));
    }
65351
public function updateGroupUser($uid, $gid) {
		$user = WechatUser::findOne($uid);
		if(!$user) {
			throw new ErrorException('数据查询失败');
		}

		if($user->groupid == $gid) {
			return true;
		}

		$data = $this->getData('/cgi-bin/groups/members/update', [
			'access_token' => $this->getAccessToken(),
		], Json::encode([
			'openid' => $user->openid,
			'to_groupid' => $gid,
		]));

		$result = $this->errcode == 0;
		if($result && $user->group->updateCounters(['count' => -1])) {
			$user->groupid = $gid;
			if($user->save()) {
				$user->refresh();
				return $user->group->updateCounters(['count' => 1]);
			}
		}

		return $result;
	}
136905
public function onConnect(Server $server, int $fd, int $fromId): void
    {
        $this->log("onConnect: Has a new client [fd:$fd] connection to the main server.(fromId: $fromId,workerId: {$server->worker_id})");

        if ($this->handler) {
            $this->handler->onConnect($server, $fd, $fromId);
        }
    }
1218070
public void addDispatcher(String dispatcherId) {
        addDispatcher(dispatcherId,
                Math.min((int) (Runtime.getCoresCount() * THREAD_MULTIPLIER), THREAD_MAX_COUNT));
    }
1067909
public function getJsonRpcResponseFromException(
        \Exception $exception,
        JsonRpcRequest $fromRequest = null
    ) : JsonRpcResponse {
        $event = new ActionEvent\OnExceptionEvent($exception, $fromRequest);
        $this->dispatchJsonRpcEvent($event::EVENT_NAME, $event);

        return $this->responseCreator->createErrorResponse($event->getException(), $fromRequest);
    }
81314
public function send($fd, $data, $ifPack = false, $topic = null)
    {
        if (!$this->portManager->websocket_enable) {
            return parent::send($fd, $data, $ifPack, $topic);
        }
        $fdinfo = $this->server->connection_info($fd);
        if (empty($fdinfo)) return false;
        $server_port = $fdinfo['server_port'];
        //允许数据监控的情况就pub
        if ($this->allow_MonitorFlowData) {
            $uid = $this->getUidFromFd($fd);
            if (!empty($uid)) {
                try {
                    get_instance()->pub('$SYS_CHANNEL/' . "$uid/send", $data);
                } catch (\Throwable $e) {

                }
            }
        }
        if ($ifPack) {
            $pack = $this->portManager->getPack($server_port);
            if ($pack != null) {
                $data = $pack->pack($data, $topic);
            }
        }
        if ($this->isWebSocket($fdinfo)) {
            return $this->server->push($fd, $data, $this->portManager->getOpCode($server_port));
        } else {
            return $this->server->send($fd, $data);
        }
    }
280021
public function fromDispatcher(JsUtils $js,$dispatcher,$startIndex=0){
		$items=$js->fromDispatcher($dispatcher);
		$url=implode("/", $items);
		if($this->urlMask==="%page%"){
			$this->urlMask=preg_replace("/[0-9]/", "%page%", $url);
		}
		for($index=$this->from;$index<=$this->to;$index++){
			if($this->getUrl($index)==$url){
				$this->setActive($index);
				break;
			}
		}
		return $this;
	}
1325045
private function handleSubscription(ConnectionInterface $from, $data) {
    if (isset($data['query'])) {
      // Request is for a query.

      $this->handleSubscriptionQuery($from, $data);
    } elseif (isset($data['uid']) && is_string($data['uid'])) {
      // Request is for a UID.

      $this->handleSubscriptionUid($from, $data);
    }
  }
1272495
public function onSwooleTask($serv, $task_id, $from_id, $data)
    {
        $type = $data['type'] ?? '';
        $message = $data['message'] ?? '';
        switch ($type) {
            case SwooleMarco::MSG_TYPE_SEND_BATCH://发送消息
                foreach ($message['fd'] as $fd) {
                    $this->send($fd, $message['data'], true);
                }

                return null;
            case SwooleMarco::MSG_TYPE_SEND_ALL://发送广播
                foreach ($this->uid_fd_table as $row) {
                    $this->send($row['fd'], $message['data'], true);
                }

                return null;
            case SwooleMarco::MSG_TYPE_SEND_ALL_FD://发送广播
                foreach ($serv->connections as $fd) {
                    $this->send($fd, $message['data'], true);
                }

                return null;
            case SwooleMarco::SERVER_TYPE_TASK://task任务
                $task_name = $message['task_name'];
                $task = $this->loader->task($task_name, $this);
                $task_fuc_name = $message['task_fuc_name'];
                $task_data = $message['task_fuc_data'];
                $task_context = $message['task_context'];
                $call = [$task->getProxy(), $task_fuc_name];
                if (is_callable($call)) {
                    //给task做初始化操作
                    $task->initialization($task_id, $from_id, $this->server->worker_pid, $task_name, $task_fuc_name, $task_context);
                    $result = sd_call_user_func_array($call, $task_data);
                } else {
                    throw new SwooleException("method $task_fuc_name not exist in $task_name");
                }
                $task->destroy();

                return $result;
            default:
                return parent::onSwooleTask($serv, $task_id, $from_id, $data);
        }
    }
254699
public function coroutineUidIsOnline($uid)
    {
        if ($this->isCluster()) {
            return ProcessManager::getInstance()->getRpcCall(ClusterProcess::class)->isOnline($uid);
        } else {
            return $this->uid_fd_table->exist($uid);
        }
    }
1271041
public function getPidFromUid($uid = 0)
    {
        $queryBuilder = self::getQueryBuilder();
        $triggerElement = $queryBuilder
            ->select('pid')
            ->from('tt_content')
            ->where(
                $queryBuilder->expr()->eq(
                    'uid',
                    $queryBuilder->createNamedParameter(abs($uid), \PDO::PARAM_INT)
                )
            )
            ->execute()
            ->fetch();
        $pid = (int)$triggerElement['pid'];
        return is_array($triggerElement) && $pid ? $pid : 0;
    }
283011
protected function callCustomHandlers($exception, $fromConsole = false)
	{
		foreach ($this->handlers as $handler)
		{
			// If this exception handler does not handle the given exception, we will just
			// go the next one. A handler may type-hint an exception that it handles so
			//  we can have more granularity on the error handling for the developer.
			if ( ! $this->handlesException($handler, $exception))
			{
				continue;
			}
			elseif ($exception instanceof HttpExceptionInterface)
			{
				$code = $exception->getStatusCode();
			}

			// If the exception doesn't implement the HttpExceptionInterface, we will just
			// use the generic 500 error code for a server side error. If it implements
			// the HttpException interfaces we'll grab the error code from the class.
			else
			{
				$code = 500;
			}

			// We will wrap this handler in a try / catch and avoid white screens of death
			// if any exceptions are thrown from a handler itself. This way we will get
			// at least some errors, and avoid errors with no data or not log writes.
			try
			{
				$response = $handler($exception, $code, $fromConsole);
			}
			catch (\Exception $e)
			{
				$response = $this->formatException($e);
			}

			// If this handler returns a "non-null" response, we will return it so it will
			// get sent back to the browsers. Once the handler returns a valid response
			// we will cease iterating through them and calling these other handlers.
			if (isset($response) && ! is_null($response))
			{
				return $response;
			}
		}
	}
335954
@Override
  public void handleSuccessfulDispatch(long clientId, long sentTime) {
    ClientData clientData = core.getClientData(clientId);
    if (sentTime == -1 || clientData == null)
      return;
    
    clientData.markedAsFailedTime = -1;
    if (clientData.markedAsFailedTime != -1) {
      LOG.info("Unmarking " + clientId + " at " + sentTime);
    }
    
    clientData.lastSentTime = sentTime;
  }
1139257
public function onPostDispatch(ActionDispatchEvent $event)
    {
        $message = sprintf(
            'Complete handle API method "%s". Response object: %s',
            $event->getAction()->getName(),
            get_class($event->getResponse())
        );

        $this->logger->debug($message);
    }
517999
public void initForNextDispatch(IExtendedRequest req) //, WebAppRequestDispatcherInfo di)
    {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {
            logger.logp(Level.FINE, CLASS_NAME,"initForNextDispatch", "req -> "+ req +" ,this -> " + this);
        }
        
        _request = req;
        if (req != null)
        {
            reqContext = ((SRTServletRequest)_request).getRequestContext();
        }
    }