Пример #1
0
 @Override
 public void preStart() {
   this.currentAuthId = keyStorage.getAuthKey();
   if (currentAuthId == 0) {
     self().send(new RequestAuthId());
   } else {
     if (isEnableLog) {
       Log.d(TAG, "Key loaded: " + currentAuthId);
     }
     self().send(new InitMTProto(currentAuthId));
   }
 }
Пример #2
0
  private void onAuthIdInvalidated(long authId) {
    if (authId != currentAuthId) {
      return;
    }

    Log.w(TAG, "Auth id invalidated");

    keyStorage.saveAuthKey(0);
    currentAuthId = 0;
    proto = null;

    callback.onAuthIdInvalidated();

    self().send(new RequestAuthId());
  }
Пример #3
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);
    }
  }