Пример #1
0
 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);
   }
 }
Пример #2
0
 @Override
 public void postStop() {
   if (proto != null) {
     proto.stopProto();
     proto = null;
   }
 }
Пример #3
0
 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);
     }
   }
 }
Пример #4
0
  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);
    }
  }
Пример #5
0
  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);
    }
  }
Пример #6
0
 private void forceNetworkCheck() {
   if (proto != null) {
     proto.forceNetworkCheck();
   }
 }
Пример #7
0
 private void onNetworkChanged(NetworkState state) {
   if (proto != null) {
     proto.onNetworkChanged(state);
   }
 }