public static void StoreSession(SignalProtocolAddress address, SessionRecord record) { string index = GetSessionCacheIndex(address.Name, address.DeviceId); lock (DBLock) { using (var ctx = new LibsignalDBContext()) { var session = ctx.Sessions .Where(s => s.DeviceId == address.DeviceId && s.Username == address.Name) .SingleOrDefault(); if (session != null) { session.Session = Base64.encodeBytes(record.serialize()); } else { ctx.Sessions.Add(new SignalSession() { DeviceId = address.DeviceId, Session = Base64.encodeBytes(record.serialize()), Username = address.Name }); } SessionsCache[index] = record; ctx.SaveChanges(); } } }
public void StoreSession(AxolotlAddress address, SessionRecord record) { if (this.OnstoreSession != null) { this.OnstoreSession(address.getName(), address.getDeviceId(), record.serialize()); } }
public void storeSession(AxolotlAddress address, SessionRecord record) { if (sessions.ContainsKey(address)) //mimic HashMap update behaviour { sessions.Remove(address); } sessions.Add(address, record.serialize()); // put }
public void setSession(SignalProtocolAddress address, SessionRecord record, string accountId) { dB.InsertOrReplace(new SessionStoreTable() { id = SessionStoreTable.generateId(address, accountId), accountId = accountId, deviceId = address.getDeviceId(), name = address.getName(), session = record.serialize() }); }
public void StoreSession(AxolotlAddress address, SessionRecord record) { DeleteSession(address); // TODO: sqlite-net combined private keys for insertOrReplace var session = new Session() { DeviceId = address.getDeviceId(), Name = address.getName(), Record = record.serialize() }; conn.InsertOrReplace(session); return; }
public static async Task SaveIdentityLocked(SignalProtocolAddress address, string identity) { LinkedList <SignalMessage> messages = null; lock (DBLock) { using (var ctx = new LibsignalDBContext()) { var old = ctx.Identities .Where(i => i.Username == address.Name) .FirstOrDefault(); //could contain stale data if (old == null) { ctx.Identities.Add(new SignalIdentity() { IdentityKey = identity, Username = address.Name, VerifiedStatus = VerifiedStatus.Default }); } else if (old.IdentityKey != identity) { if (old.VerifiedStatus == VerifiedStatus.Verified) { old.VerifiedStatus = VerifiedStatus.Unverified; } old.IdentityKey = identity; var oldSessions = ctx.Sessions .Where(s => s.Username == address.Name); foreach (var oldSession in oldSessions) { SessionRecord sessionRecord = new SessionRecord(Base64.Decode(oldSession.Session)); sessionRecord.archiveCurrentState(); oldSession.Session = Base64.EncodeBytes(sessionRecord.serialize()); SessionsCache[GetSessionCacheIndex(address.Name, oldSession.DeviceId)] = sessionRecord; } messages = InsertIdentityChangedMessages(address.Name); } ctx.SaveChanges(); } } if (messages != null) { await SignalLibHandle.Instance.DispatchHandleIdentityKeyChange(messages); } }
public void StoreSession(SignalProtocolAddress address, SessionRecord record) { sessions[address] = record.serialize(); }
public void StoreSession(AxolotlAddress address, SessionRecord record) { sessions[address] = record.serialize(); }