撤回消息
@param string|array $msgSeq
@return BaseResponse
@throws Exception\TIMException
767487
public function recallMessage($msgSeq)
    {
        $msgSeqList = is_array($msgSeq) ? $msgSeq : [$msgSeq];
        $request = new RecallGroupMessageRequest($this->groupId, $msgSeqList);
        $response = new BaseResponse();
        return $this->client->sendRequest($request, $response);
    }
1140628
public function clientRequest(Client $client, ExecuteRequest $msg)
    {
        $requestId = $msg->getRequestId();
        if (!$requestId) {
            // No requestId given, generate a unique one.
            do {
                $requestId = sha1(uniqid());
            } while (isset($this->request[$requestId]));
        }

        if ($this->storage->has($requestId)) {
            $this->getLogger()->info(
                sprintf(
                    'Client %s wants to execute request %s. '.
                    'Since there already is a result for that request, '.
                    'it will be sent back immediately.',
                    bin2hex($client->getId()),
                    $requestId
                )
            );

            $this->reply(
                $client,
                new ExecuteResponse(
                    $requestId,
                    $this->storage->get($requestId)
                )
            );

            return;
        }

        // The Client always needs to receive this
        // response, so just send it right away.
        $this->reply($client, new ExecuteResponse($requestId));

        // Now actually handle the message.
        $request = $this->getRequest($requestId);

        if ($request) {
            $this->getLogger()->info(
                sprintf(
                    'Client %s wants to execute already known request %s.',
                    bin2hex($client->getId()),
                    $requestId
                )
            );

            return;
        }

        $action = $msg->getAction();
        $params = $msg->getParams();

        $this->getLogger()->info(
            sprintf(
                'New request %s from client %s for action %s',
                $requestId,
                bin2hex($client->getId()),
                $action
            )
        );

        $this->addRequest(new Request($requestId, $action, $params));

        if (!$this->storage->has($requestId)) {
            $this->addWorkerQueue($requestId);
        }
    }
13975
public function sendSMS( $mobile, $msg, $needstatus = 'false') {

		//创蓝接口参数
		$postArr = array (
				          'account' => $this->apiAccount,
				          'pswd' => $this->apiPassword,
				          'msg' => $msg,
				          'mobile' => $mobile,
				          'needstatus' => $needstatus
                     );

		$result = $this->curlPost( $this->apiSendUrl , $postArr);
		return $result;
	}
713156
function CreateSequence2008($seq='adodbseq',$start=1)
	{
		if($this->debug) ADOConnection::outp("<hr>CreateSequence($seq,$start)");
		sqlsrv_begin_transaction($this->_connectionID);
		$start -= 1;
		$this->Execute("create table $seq (id int)");//was float(53)
		$ok = $this->Execute("insert into $seq with (tablock,holdlock) values($start)");
		if (!$ok) {
			if($this->debug) ADOConnection::outp("<hr>Error: ROLLBACK");
			sqlsrv_rollback($this->_connectionID);
			return false;
		}
		sqlsrv_commit($this->_connectionID);
		return true;
	}
1332048
public function notRegexp($pattern, $msg)
    {
        if(preg_match($pattern, (string)$this->_value)) {
            $this->_errors[] = $msg;
        }
        return $this;
    }
1024637
public function log($msg, $timestamp = true)
    {
        if ($timestamp) {
            $timestamp = strftime("%Y-%m-%d %H:%M:%S");
            $msg = "[{$timestamp}] {$msg}";
        }
        $this->addResult($msg);
        if ($this->verbose) echo $msg . PHP_EOL;
    }
413673
public function msgOk ($data = null, $groups = "", $message = "", $httpStatusCode = Response::HTTP_ACCEPTED)
    {
        return $this->responseOk ($data, $groups, $message, $httpStatusCode);
    }
1111980
public static function parse(string $msg): Message
    {
        $decoded = json_decode($msg);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new Error(json_last_error_msg(), ErrorCode::PARSE_ERROR);
        }
        if (Notification::isNotification($decoded)) {
            $obj = new Notification($decoded->method, $decoded->params ?? null);
        } else if (Request::isRequest($decoded)) {
            $obj = new Request($decoded->id, $decoded->method, $decoded->params ?? null);
        } else if (SuccessResponse::isSuccessResponse($decoded)) {
            $obj = new SuccessResponse($decoded->id, $decoded->result);
        } else if (ErrorResponse::isErrorResponse($decoded)) {
            $obj = new ErrorResponse($decoded->id, new Error($decoded->error->message, $decoded->error->code, $decoded->error->data ?? null));
        } else {
            throw new Error('Invalid message', ErrorCode::INVALID_REQUEST);
        }
        return $obj;
    }
851471
public function handle(
        $msgType,
        \fpoirotte\Pssht\Wire\Decoder $decoder,
        \fpoirotte\Pssht\Transport $transport,
        array &$context
    ) {
        $hostAlgo   = null;
        foreach ($context['kex']['client']->getServerHostKeyAlgos() as $algo) {
            if (isset($context['serverKeys'][$algo])) {
                $hostAlgo = $algo;
                break;
            }
        }
        if ($hostAlgo === null) {
            throw new \RuntimeException();
        }
        $response   = $this->createResponse($decoder, $transport, $context, $hostAlgo);

        $logging    = \Plop\Plop::getInstance();
        $secret = gmp_strval($response->getSharedSecret(), 16);
        $logging->debug(
            "Shared secret:\r\n%s",
            array(
                wordwrap($secret, 16, ' ', true)
            )
        );

        $logging->debug(
            'Hash: %s',
            array(
                wordwrap(bin2hex($response->getExchangeHash()), 16, ' ', true)
            )
        );

        if (!isset($context['sessionIdentifier'])) {
            $context['sessionIdentifier'] = $response->getExchangeHash();
        }
        $context['DH'] = $response;
        $transport->writeMessage($response);
        return true;
    }
913910
public function receive($envelope, $queue) {
        $nowTime = time();
        // 保持心跳
        $this->ping();

        $msgJson = $envelope->getBody();
        $msgJson = json_decode($msgJson, true);
        if ($msgJson['eventKey'] == 'Console') {
            $queue->ack($envelope->getDeliveryTag());
            switch ($msgJson['data']) {
                case 'reload':
                    echo sprintf("[date:%s]Event RabbitMQ: queue key '%s' reload.\n", date('Y-m-d H:i:s', $nowTime), $this->queueKey);
                    $this->rabbtMq->disconnection();
                    exit();
                    break;
                case 'ping':
                    echo sprintf("[date:%s]Event RabbitMQ: queue key '%s' ping.\n", date('Y-m-d H:i:s', $nowTime), $this->queueKey);
                    return;
            }
            return ;
        }

        // 消息转发到指定队列执行
        if ($this->queueConfig['forward']) {
            $msgJson['forward'] = $this->queueKey ;
            $msgJson['forwardLists'][] = $this->queueKey;// 转发列表，可能发生多次转发
            $forwardQueueConfig = RabbitMqConfig::getQueue($this->queueConfig['forward_queue_key']);
            // 消息转发
            $rabbitMq = new RabbitMq($this->exchangeName, $this->exchangeType);
            $rabbitMq->send($msgJson, $forwardQueueConfig['route_key']);
            $queue->ack($envelope->getDeliveryTag());
            return;
        }

        // 设置事件消费是的队列信息
        $this->eventUseQueueKey     = $this->queueKey;
        $this->eventUseQueueConfig  = $this->queueConfig;
        $this->eventUseQueueType    = $this->queueType;
        // 消息来自转发
        if (isset($msgJson['forward'])) {
            $this->eventUseQueueKey     = $msgJson['forwardLists'][0];
            $this->eventUseQueueConfig  = RabbitMqConfig::getQueue($this->eventUseQueueKey);
            $this->eventUseQueueType    = $this->eventUseQueueConfig['queue_type'];
        }

        // 消息版本不一致, 队列重启
        if ($this->version != $msgJson['version']) {
            echo sprintf("[date:%][message-version: %s][queue-version: %]The message version is different from the queue version \n", date('Y-m-d H:i:s', $nowTime));
            $queue->ack($envelope->getDeliveryTag());
            exit();
        }
        
        try {

            $callbackResult = $this->callback($msgJson);
            if ($callbackResult->getCode() === Code::SUCCESS) {
                $queue->ack($envelope->getDeliveryTag());
                $this->updateAdditional($msgJson, $callbackResult, null);
            } else {
                $queue->ack($envelope->getDeliveryTag());
                $this->updateAdditional($msgJson, $callbackResult, null);
            }

        } catch (\Exception $e) { // 非法消息,直接确认
            echo $e;
            $queue->ack($envelope->getDeliveryTag());
            $callbackResult = new CallbackResult(Code::EXCEPTION, [], '异常');
            $this->updateAdditional($msgJson, $callbackResult, $e);
            return ;
        }

    }
261266
public function handle(
        $msgType,
        \fpoirotte\Pssht\Wire\Decoder $decoder,
        \fpoirotte\Pssht\Transport $transport,
        array &$context
    ) {
        if ($this->connection !== null) {
            // Silently ignore subsequent authentication requests
            // after a successful authentication took place.
            return true;
        }

        $encoder    = new \fpoirotte\Pssht\Wire\Encoder();
        $user       = $decoder->decodeString();
        $service    = $decoder->decodeString();
        $method     = $decoder->decodeString();

        $encoder->encodeString($user);
        $encoder->encodeString($service);
        $encoder->encodeString($method);
        $decoder->getBuffer()->unget($encoder->getBuffer()->get(0));

        if (!isset($context['authMethods'])) {
            $context['authMethods']     = $this->methods;
        }

        if (!isset($context['banner'])) {
            $context['banner'] = (string) $transport->getBanner();
            if ($context['banner'] !== '') {
                $response = new \fpoirotte\Pssht\Messages\USERAUTH\BANNER($context['banner']);
                $transport->writeMessage($response);
            }
        }

        if (!isset($context['authMethods'][$method])) {
            return $this->failure($transport, $context);
        }

        $messagesCls = array(
            'none' =>
                '\\fpoirotte\\Pssht\\Messages\\USERAUTH\\REQUEST\\None',
            'hostbased' =>
                '\\fpoirotte\\Pssht\\Messages\\USERAUTH\\REQUEST\\HostBased',
            'password' =>
                '\\fpoirotte\\Pssht\\Messages\\USERAUTH\\REQUEST\\Password',
            'publickey' =>
                '\\fpoirotte\\Pssht\\Messages\\USERAUTH\\REQUEST\\PublicKey',
        );
        $methodObj  = $context['authMethods'][$method];
        $message    = $messagesCls[$method]::unserialize($decoder);

        switch ($methodObj->check($message, $transport, $context)) {
            case AuthenticationInterface::CHECK_IGNORE:
                return true;

            case AuthenticationInterface::CHECK_REJECT:
                return $this->failure($transport, $context);

            case AuthenticationInterface::CHECK_OK:
                break;

            default:
                throw new \RuntimeException();
        }

        switch ($methodObj->authenticate($message, $transport, $context)) {
            case AuthenticationInterface::AUTH_REMOVE:
                unset($context['authMethods'][$method]);
                // Do not break.

            case AuthenticationInterface::AUTH_REJECT:
                return $this->failure($transport, $context);

            case AuthenticationInterface::AUTH_ACCEPT:
                break;

            default:
                throw new \RuntimeException();
        }

        unset($context['authMethods'][$method]);
        $response = new \fpoirotte\Pssht\Messages\USERAUTH\SUCCESS();
        $this->connection = new \fpoirotte\Pssht\Connection($transport);
        $transport->writeMessage($response);

        $compressor = $transport->getCompressor();
        if ($compressor instanceof \fpoirotte\Pssht\DelayedCompressionInterface) {
            $compressor->setAuthenticated();
        }
        $uncompressor = $transport->getUncompressor();
        if ($uncompressor instanceof \fpoirotte\Pssht\DelayedCompressionInterface) {
            $uncompressor->setAuthenticated();
        }

        return true;
    }
470111
public function handle(
        $msgType,
        \fpoirotte\Pssht\Wire\Decoder $decoder,
        \fpoirotte\Pssht\Transport $transport,
        array &$context
    ) {
        $message    = \fpoirotte\Pssht\Messages\SERVICE\REQUEST::unserialize($decoder);
        $service    = $message->getServiceName();

        if ($service === 'ssh-userauth') {
            $response = new \fpoirotte\Pssht\Messages\SERVICE\ACCEPT($service);
            $transport->setHandler(
                \fpoirotte\Pssht\Messages\USERAUTH\REQUEST\Base::getMessageId(),
                $this->userAuthRequestHandler
            );
        } else {
            $response = new DISCONNECT(
                DISCONNECT::SSH_DISCONNECT_SERVICE_NOT_AVAILABLE,
                'No such service'
            );
        }
        $transport->writeMessage($response);
        return true;
    }
412667
public function record($msg, $type = 'info', array $context = [])
    {
        if (is_string($msg)) {
            $replace = [];
            foreach ($context as $key => $val) {
                $replace['{' . $key . '}'] = $val;
            }

            $msg = strtr($msg, $replace);
        }

        $this->log[$type][] = $msg;

        if (PHP_SAPI == 'cli') {
            // 命令行日志实时写入
            $this->save();
        }

        return $this;
    }
434757
public function reply($msg = array(), $return = false)
    {
        if (empty($msg)) {
            if (empty($this->_msg)) {   //防止不先设置回复内容，直接调用reply方法导致异常
                return false;
            }
            $msg = $this->_msg;
        }
        $xmldata = Tools::arr2xml($msg);
        if ($this->encrypt_type == 'aes') { //如果来源消息为加密方式
            !class_exists('Prpcrypt', false) && require __DIR__ . '/Lib/Prpcrypt.php';
            $pc = new Prpcrypt($this->encodingAesKey);
            // 如果是第三方平台，加密得使用 component_appid
            $array = $pc->encrypt($xmldata, empty($this->config['component_appid']) ? $this->appid : $this->config['component_appid']);
            $ret = $array[0];
            if ($ret != 0) {
                Tools::log('Encrypt Error!', "ERR - {$this->appid}");
                return false;
            }
            $timestamp = time();
            $nonce = rand(77, 999) * rand(605, 888) * rand(11, 99);
            $encrypt = $array[1];
            $tmpArr = array($this->token, $timestamp, $nonce, $encrypt);
            sort($tmpArr, SORT_STRING);
            $signature = sha1(implode($tmpArr));
            $format = "<xml><Encrypt><![CDATA[%s]]></Encrypt><MsgSignature><![CDATA[%s]]></MsgSignature><TimeStamp>%s</TimeStamp><Nonce><![CDATA[%s]]></Nonce></xml>";
            $xmldata = sprintf($format, $encrypt, $signature, $timestamp, $nonce);
        }
        if ($return) {
            return $xmldata;
        }
        echo $xmldata;
    }
621520
public function badRequest($msg = '', $errorCode = null, $headers = [])
    {
        return $this->getErrorResponse($msg, $errorCode, self::HTTP_BAD_REQUEST, $headers);
    }
542289
private function write(string $file, string $msg)
    {
        // 将文件名中的目录分隔符标准化
        $file = str_replace('\\', '/', $file);

        // 在日志目录下创建年目录
        $path = $this->dirRoot . date('Y-m-d') . '/' . $file . '.log';
        makeDir(dirname($path));

        // 写入文件
        return write($path, $msg, FILE_APPEND | LOCK_EX);
    }
1136063
protected function throwException($code, $msg)
    {
        $args = func_get_args();

        $code = array_shift($args);

        throw new \RuntimeException(call_user_func_array('sprintf', $args), $code);
    }