Huawei Api Client 连接结束方法
@param rstCode client 连接结果码
765316
private void onConnectEnd(final int rstCode) {
        HMSAgentLog.d("connect end:" + rstCode);

        synchronized (CALLBACK_LOCK) {
            // 回调各个回调接口连接结束
            for (IClientConnectCallback callback : connCallbacks) {
                aSysnCallback(rstCode, callback);
            }
            connCallbacks.clear();

            // 恢复默认不显示
            allowResolveConnectError = false;
        }

        synchronized (STATIC_CALLBACK_LOCK) {
            // 回调各个回调接口连接结束
            for (IClientConnectCallback callback : staticCallbacks) {
                aSysnCallback(rstCode, callback);
            }
            staticCallbacks.clear();
        }
    }
1177417
public void requestSmsVerificationCode(boolean androidSmsRetrieverSupported, Optional<String> captchaToken) throws IOException {
    this.pushServiceSocket.requestSmsVerificationCode(androidSmsRetrieverSupported, captchaToken);
  }
367003
function(name,params,callback){

        if($bridge['callHandler']){

          $bridge.callHandler(name,params,function(data){
            if(typeof callback == 'function'){
              /* 解决部分系统加载延迟导致 ios/android 不响应问题 */
              setTimeout(function(){
                callback(data);
              },bridgeConfig.bridgeWebViewDelay)
            }
          })

        }else {
          console.log("don't built-in WebView invoking ",name,'{callHandler}')
        }
    }
1146721
public void connect(IClientConnectCallback callback, boolean allowResolve) {

        if (context == null) {
            aSysnCallback(HMSAgent.AgentResultCode.HMSAGENT_NO_INIT, callback);
            return;
        }

        HuaweiApiClient client =  getApiClient();
        // client 有效，则直接回调
        if (client != null && client.isConnected()) {
            HMSAgentLog.d("client is valid");
            aSysnCallback(HMSAgent.AgentResultCode.HMSAGENT_SUCCESS, callback);
            return;
        } else {
            // client无效，将callback加入队列，并启动连接
            synchronized (CALLBACK_LOCK) {
                HMSAgentLog.d("client is invalid：size=" + connCallbacks.size());
                allowResolveConnectError = allowResolveConnectError || allowResolve;
                if (connCallbacks.isEmpty()) {
                    connCallbacks.add(callback);

                    // 连接尝试最大次数
                    curLeftResolveTimes = MAX_RESOLVE_TIMES;

                    startConnect();
                } else {
                    connCallbacks.add(callback);
                }
            }
        }
    }
651413
public static void tradePage(HttpServletResponse httpResponse, AlipayTradePagePayModel model, String notifyUrl,
			String returnUrl) throws AlipayApiException, IOException {
		AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
		request.setBizModel(model);
		request.setNotifyUrl(notifyUrl);
		request.setReturnUrl(returnUrl);
		String form = AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().pageExecute(request).getBody();// 调用SDK生成表单
		httpResponse.setContentType("text/html;charset=" + AliPayApiConfigKit.getAliPayApiConfig().getCharset());
		httpResponse.getWriter().write(form);// 直接将完整的表单html输出到页面
		httpResponse.getWriter().flush();
		httpResponse.getWriter().close();
	}
510310
protected ResponseFuture doInvokeAsync(SofaRequest request, RpcInternalContext rpcContext,
                                           InvokeContext invokeContext, int timeoutMillis)
        throws RemotingException, InterruptedException {
        SofaResponseCallback listener = request.getSofaResponseCallback();
        if (listener != null) {
            // callback调用
            InvokeCallback callback = new BoltInvokerCallback(transportConfig.getConsumerConfig(),
                transportConfig.getProviderInfo(), listener, request, rpcContext,
                ClassLoaderUtils.getCurrentClassLoader());
            // 发起调用
            RPC_CLIENT.invokeWithCallback(url, request, invokeContext, callback, timeoutMillis);
            return null;
        } else {
            // future 转为 callback
            BoltResponseFuture future = new BoltResponseFuture(request, timeoutMillis);
            InvokeCallback callback = new BoltFutureInvokeCallback(transportConfig.getConsumerConfig(),
                transportConfig.getProviderInfo(), future, request, rpcContext,
                ClassLoaderUtils.getCurrentClassLoader());
            // 发起调用
            RPC_CLIENT.invokeWithCallback(url, request, invokeContext, callback, timeoutMillis);
            future.setSentTime();
            return future;
        }
    }
523909
public void close(ErrorCode rstStatusCode, @Nullable IOException errorException)
      throws IOException {
    if (!closeInternal(rstStatusCode, errorException)) {
      return; // Already closed.
    }
    connection.writeSynReset(id, rstStatusCode);
  }
1072883
public static SpdyStreamStatus valueOf(int code) {
        if (code == 0) {
            throw new IllegalArgumentException(
                    "0 is not a valid status code for a RST_STREAM");
        }

        switch (code) {
        case 1:
            return PROTOCOL_ERROR;
        case 2:
            return INVALID_STREAM;
        case 3:
            return REFUSED_STREAM;
        case 4:
            return UNSUPPORTED_VERSION;
        case 5:
            return CANCEL;
        case 6:
            return INTERNAL_ERROR;
        case 7:
            return FLOW_CONTROL_ERROR;
        case 8:
            return STREAM_IN_USE;
        case 9:
            return STREAM_ALREADY_CLOSED;
        case 10:
            return INVALID_CREDENTIALS;
        case 11:
            return FRAME_TOO_LARGE;
        }

        return new SpdyStreamStatus(code, "UNKNOWN (" + code + ')');
    }
805671
@Override
    public void onConnect(final int rst, final HuaweiApiClient client) {
        //需要在子线程中执行删除TOKEN操作
        ThreadUtil.INST.excute(new Runnable() {
            @Override
            public void run() {
                //调用删除TOKEN需要传入通过getToken接口获取到TOKEN，并且需要对TOKEN进行非空判断
                if (!TextUtils.isEmpty(token)){
                    if (client == null || !ApiClientMgr.INST.isConnect(client)) {
                        HMSAgentLog.e("client not connted");
                        onDeleteTokenResult(rst);
                    } else {
                        try {
                            HuaweiPush.HuaweiPushApi.deleteToken(client, token);
                            onDeleteTokenResult(HMSAgent.AgentResultCode.HMSAGENT_SUCCESS);
                        } catch (Exception e) {
                            HMSAgentLog.e("删除TOKEN失败:" + e.getMessage());
                            onDeleteTokenResult(HMSAgent.AgentResultCode.CALL_EXCEPTION);
                        }
                    }
                } else {
                    HMSAgentLog.e("删除TOKEN失败: 要删除的token为空");
                    onDeleteTokenResult(HMSAgent.AgentResultCode.EMPTY_PARAM);
                }
            }
        });
    }
332117
@Override
    public void onConnect(int rst, HuaweiApiClient client) {
        if (client == null || !ApiClientMgr.INST.isConnect(client)) {
            HMSAgentLog.e("client not connted");
            onSignInResult(rst, null);
            return;
        }

        Activity curActivity = ActivityMgr.INST.getLastActivity();
        if (curActivity == null) {
            HMSAgentLog.e("activity is null");
            onSignInResult(HMSAgent.AgentResultCode.NO_ACTIVITY_FOR_USE, null);
            return;
        }
		
        PendingResult<SignInResult> signInResult = HuaweiId.HuaweiIdApi.signIn(curActivity, client);
        signInResult.setResultCallback(new ResultCallback<SignInResult>() {
            @Override
            public void onResult(SignInResult result) {
                disposeSignInResult(result);
            }
        });
    }
5219
private static void logRpcFly(JSONObject msgJson, ChannelHandlerContext ctx) {
        try {
            String ssid = msgJson.getString("$ssid");
            String from = msgJson.getString("$LOCAL_NODE_ID");
            String msgType = msgJson.getString("$msgType");
            if (ssid != null) {
                long start = (long) msgJson.remove("$timestampMs");//目前是用完删掉,避免传递到业务层
                LOG.debug(new JSONObject() {{
                    put("cost", System.currentTimeMillis() - start);
                    put("type", "rpcFly");
                    put("ssid", ssid);
                    put("from", from);
                    /*put("length", msgStr.length());*/
                    /*put("fullMsg", msgStr);*/
                    put("msgType", msgType);
                    put("client", ctx.channel().localAddress());
                    put("server", ctx.channel().remoteAddress());
                }});
            }
        } catch (Throwable e) {
            LOG.error(e);
        }
    }
1135822
@Override
    public void doReportStat(SofaTracerSpan sofaTracerSpan) {
        //tags
        Map<String, String> tagsWithStr = sofaTracerSpan.getTagsWithStr();

        StatMapKey statKey = new StatMapKey();

        String fromApp = getFromApp(tagsWithStr);
        String toApp = getToApp(tagsWithStr);
        String zone = getZone(tagsWithStr);

        //service name
        String serviceName = tagsWithStr.get(RpcSpanTags.SERVICE);
        //method name
        String methodName = tagsWithStr.get(RpcSpanTags.METHOD);

        statKey.setKey(buildString(new String[] { fromApp, toApp, serviceName, methodName }));
        String resultCode = tagsWithStr.get(RpcSpanTags.RESULT_CODE);
        statKey.setResult(isSuccess(resultCode) ? "Y" : "N");
        statKey.setEnd(buildString(new String[] { getLoadTestMark(sofaTracerSpan), zone }));
        statKey.setLoadTest(TracerUtils.isLoadTest(sofaTracerSpan));

        statKey.addKey(RpcSpanTags.LOCAL_APP, tagsWithStr.get(RpcSpanTags.LOCAL_APP));
        statKey.addKey(RpcSpanTags.REMOTE_APP, tagsWithStr.get(RpcSpanTags.REMOTE_APP));
        statKey.addKey(RpcSpanTags.SERVICE, serviceName);
        statKey.addKey(RpcSpanTags.METHOD, methodName);
        //次数和耗时，最后一个耗时是单独打印的字段
        long duration = sofaTracerSpan.getEndTime() - sofaTracerSpan.getStartTime();
        long[] values = new long[] { 1, duration };
        this.addStat(statKey, values);
    }
992270
@Override
    public Connection getConnection(RpcClient rpcClient, ClientTransportConfig transportConfig, Url url) {
        if (rpcClient == null || transportConfig == null || url == null) {
            return null;
        }
        Connection connection = urlConnectionMap.get(transportConfig);
        if (connection != null && !connection.isFine()) {
            closeConnection(rpcClient, transportConfig, url);
            connection = null;
        }
        if (connection == null) {
            try {
                connection = rpcClient.getConnection(url, url.getConnectTimeout());
            } catch (Exception e) {
                LOGGER.warn("get connection failed in url," + url);
            }
            if (connection == null) {
                return null;
            }
            // 保存唯一长连接
            Connection oldConnection = urlConnectionMap.putIfAbsent(transportConfig, connection);
            if (oldConnection != null) {
                if (LOGGER.isWarnEnabled()) {
                    LOGGER.warn("Multiple threads init ClientTransport with same key:" + url);
                }
                //only if new connection is not equals old connection,we can close it
                if (connection != oldConnection) {
                    rpcClient.closeStandaloneConnection(connection); //如果同时有人插入，则使用第一个
                    connection = oldConnection;
                }
            } else {

                // 增加计数器
                AtomicInteger counter = connectionRefCounter.get(connection);
                if (counter == null) {
                    counter = new AtomicInteger(0);
                    AtomicInteger oldCounter = connectionRefCounter.putIfAbsent(connection, counter);
                    if (oldCounter != null) {
                        counter = oldCounter;
                    }
                }
                int currentCount = counter.incrementAndGet();
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Bolt client transport {} of {}, current ref count is: {}", url.toString(),
                        NetUtils.channelToString(connection.getLocalAddress(), connection.getRemoteAddress()),
                        currentCount);
                }
            }
        }
        return connection;
    }
258021
def verifyCode(self, sessionId, code):
        

        desc = {
            "name": "SMSVerifyCodeResult",
            "desc": " VerifyCode 返回结果",
            "fields": [{
                "name": "code",
                "type": "Integer",
                "desc": "返回码，200 为正常。"
            }, {
                "name": "success",
                "type": "Boolean",
                "desc": "true 验证成功，false 验证失败。"
            }, {
                "name": "errorMessage",
                "type": "String",
                "desc": "错误信息。"
            }]
        }
        r = self.call_api(
            method=('SMS', 'POST', 'application/x-www-form-urlencoded'),
            action='/verifyCode.json',
            params={"sessionId": sessionId,
                    "code": code})
        return Response(r, desc)
899889
function TransmitOralProcess(client, req) {
    return new Promise(function (resolve, reject) {
        // 通过client对象调用想要访问的接口，需要传入请求对象以及响应回调函数
        client.TransmitOralProcess(req, function (err, response) {
            if (err) {
                reject(err)
                return;
            }
            // 请求正常返回，打印response对象
            resolve(response)
        });
    })
}
486360
private void showFinal(boolean show, Activity activity, HuaweiApiClient client) {

        // 保存当前浮标显示状态，以便出现异常浮标消失后，能够恢复
        isCurFloatShow = show;

        Activity curActivity = activity!=null ? activity : ActivityMgr.INST.getLastActivity();

        // 取得当前 activity 用于展示浮标
        if (curActivity == null) {
            HMSAgentLog.e("activity is null");
            return;
        }

        if (show) {
            if (client == null || !client.isConnected()) {
                HMSAgentLog.e("client is invalid");
                ApiClientMgr.INST.connect(new EmptyConnectCallback("try connect end when show float:"), false);
                return;
            }

            HMSAgentLog.d("show begin");
            PendingResult<ShowFloatWindowResult> pendingRst = HuaweiGame.HuaweiGameApi.showFloatWindow(client, curActivity);
            pendingRst.setResultCallback(new ShowFloatWindowCallBack());
        } else {
            HMSAgentLog.d("hide");
            HuaweiGame.HuaweiGameApi.hideFloatWindow(client, curActivity);
        }
    }
1311549
private void markUsed(EtlEventData data) throws ZkNoNodeException, ZkException {
        String path = StagePathUtils.getProcess(data.getPipelineId(), data.getProcessId());
        // 序列化
        ProcessNodeEventData eventData = new ProcessNodeEventData();
        Long nid = ArbitrateConfigUtils.getCurrentNid();
        eventData.setNid(nid);
        eventData.setStatus(ProcessNodeEventData.Status.USED);// 标记为已使用
        eventData.setMode(ArbitrateMode.RPC);// 直接声明为rpc模式
        byte[] bytes = JsonUtils.marshalToByte(eventData);
        zookeeper.writeData(path, bytes);
    }