private void forceResend(long randomId) {
   RequestHolder holder = requests.get(randomId);
   if (holder != null) {
     if (holder.protoId != 0) {
       idMap.remove(holder.protoId);
       proto.cancelRpc(holder.protoId);
     }
     long mid = proto.sendRpcMessage(holder.message);
     holder.protoId = mid;
     idMap.put(mid, randomId);
   }
 }
 @Override
 public void postStop() {
   if (proto != null) {
     proto.stopProto();
     proto = null;
   }
 }
 private void cancelRequest(long randomId) {
   RequestHolder holder = requests.get(randomId);
   if (holder != null) {
     requests.remove(randomId);
     if (holder.protoId != 0 && proto != null) {
       idMap.remove(holder.protoId);
       proto.cancelRpc(holder.protoId);
     }
   }
 }
  private void performRequest(long randomId, Request message, RpcCallback callback) {
    Log.d(TAG, "-> request#" + randomId + ": " + message);
    // Log.d(TAG, message + " rid#" + randomId);
    RequestHolder holder =
        new RequestHolder(
            Environment.getCurrentTime(),
            randomId,
            new RpcRequest(message.getHeaderKey(), message.toByteArray()),
            callback);
    requests.put(holder.publicId, holder);

    if (proto != null) {
      long mid = proto.sendRpcMessage(holder.message);
      holder.protoId = mid;
      idMap.put(mid, randomId);
      // Log.d(TAG, message + " rid#" + randomId + " <- mid#" + mid);
    }
  }
  private void createMtProto(long key) {
    Log.d(TAG, "Creating proto");
    keyStorage.saveAuthKey(key);
    currentAuthId = key;

    proto =
        new MTProto(
            key,
            RandomUtils.nextRid(),
            endpoints,
            new ProtoCallback(key),
            networkProvider,
            isEnableLog,
            getPath() + "/proto#" + NEXT_PROTO_ID.incrementAndGet(),
            minDelay,
            maxDelay,
            maxFailureCount);

    for (RequestHolder holder : requests.values()) {
      holder.protoId = proto.sendRpcMessage(holder.message);
      idMap.put(holder.protoId, holder.publicId);
      // Log.d(TAG, holder.message + " rid#" + holder.publicId + " <- mid#" + holder.protoId);
    }
  }
 private void forceNetworkCheck() {
   if (proto != null) {
     proto.forceNetworkCheck();
   }
 }
 private void onNetworkChanged(NetworkState state) {
   if (proto != null) {
     proto.onNetworkChanged(state);
   }
 }