@Override public void tcpConnectionReceivedData(TcpConnection connection, byte[] data) { SerializedData is = new SerializedData(data); long keyId = is.readInt64(); if (keyId == 0) { long messageId = is.readInt64(); if (processedMessageIds.contains(messageId)) { Log.d( "tmessages", String.format("===== Duplicate message id %d received, ignoring", messageId)); return; } int messageLength = is.readInt32(); int constructor = is.readInt32(); TLObject object = TLClassStore.Instance().TLdeserialize(is, constructor); if (object != null) { processedMessageIds.add(messageId); } processMessage(object, messageId); } else { Log.d("tmessages", "***** Received encrypted message while in handshake, restarting"); beginHandshake(true); } }
public Datacenter(SerializedData data, int version) { if (version == 0) { datacenterId = data.readInt32(); String address = data.readString(); addresses.add(address); int port = data.readInt32(); ports.put(address, port); int len = data.readInt32(); if (len != 0) { authKey = data.readData(len); } len = data.readInt32(); if (len != 0) { authKeyId = data.readInt64(); } authorized = data.readInt32() != 0; len = data.readInt32(); for (int a = 0; a < len; a++) { ServerSalt salt = new ServerSalt(); salt.validSince = data.readInt32(); salt.validUntil = data.readInt32(); salt.value = data.readInt64(); if (authServerSaltSet == null) { authServerSaltSet = new ArrayList<ServerSalt>(); } authServerSaltSet.add(salt); } } else if (version == 1) { int currentVersion = data.readInt32(); if (currentVersion == 2 || currentVersion == 3 || currentVersion == 4) { datacenterId = data.readInt32(); if (currentVersion >= 3) { lastInitVersion = data.readInt32(); } int len = data.readInt32(); for (int a = 0; a < len; a++) { String address = data.readString(); addresses.add(address); ports.put(address, data.readInt32()); } len = data.readInt32(); if (len != 0) { authKey = data.readData(len); } if (currentVersion == 4) { authKeyId = data.readInt64(); } else { len = data.readInt32(); if (len != 0) { authKeyId = data.readInt64(); } } authorized = data.readInt32() != 0; len = data.readInt32(); for (int a = 0; a < len; a++) { ServerSalt salt = new ServerSalt(); salt.validSince = data.readInt32(); salt.validUntil = data.readInt32(); salt.value = data.readInt64(); if (authServerSaltSet == null) { authServerSaltSet = new ArrayList<ServerSalt>(); } authServerSaltSet.add(salt); } } } else if (version == 2) { } readCurrentAddressAndPortNum(); }