public void MigrateSession(AriesSession oldSession, AriesSession newSession) { MigrationCount++; var oldIO = oldSession.IoSession; oldSession.Migrate(newSession.IoSession); //remove the new session as its connection has been migrated to the old. _Sessions.Remove(newSession); //may still be connected. disconnect the old tcp connection. oldIO.SetAttribute("s", null); oldIO.Write(new ServerByePDU()); Task.Delay(100).ContinueWith((task) => { oldIO.Close(true); }); foreach (var interceptor in _SessionInterceptors) { try { interceptor.SessionMigrated(oldSession); } catch (Exception ex) { LOG.Error(ex); } } oldSession.Write(new HostOnlinePDU { ClientBufSize = 4096, HostVersion = 0x7FFF, HostReservedWords = 0 }); }
public void SessionCreated(IoSession session) { LOG.Info("[SESSION-CREATE (" + Config.Call_Sign + ")]"); //Setup session var ariesSession = new AriesSession(session); session.SetAttribute("s", ariesSession); _Sessions.Add(ariesSession); foreach (var interceptor in _SessionInterceptors) { try{ interceptor.SessionCreated(ariesSession); }catch (Exception ex) { LOG.Error(ex); } } if (TimeoutIfNoAuth) { ariesSession.TimeoutIfNoAuth(20000); } //Ask for session info session.Write(new RequestClientSession()); }
public bool AttemptMigration(AriesSession newSession, string userID, string password) { //search for a session for a specific user uint avatarID; if (!uint.TryParse(userID, out avatarID)) { LOG.Info($"Rejected migration: could not parse userID {userID}"); return(false); } var session = _Sessions.GetByAvatarId(avatarID); if (session == null) { LOG.Info($"Rejected migration: could not find session for userID {userID}"); return(false); } if ((string)session.GetAttribute("sessionKey") != password) { var nullified = (session.GetAttribute("sessionKey") == null) ? "null" : "non-null"; LOG.Info($"Rejected migration: incorrect session key for user {userID}. (session key is {nullified})"); return(false); } LOG.Info($"Migrating session for user {userID}..."); newSession.Authenticate(password); //make sure the new session knows that authentication has completed. MigrateSession((AriesSession)session, newSession); return(true); }
public void SessionCreated(IoSession session) { LOG.Info("[SESSION-CREATE]"); //Setup session var ariesSession = new AriesSession(session); session.SetAttribute("s", ariesSession); _Sessions.Add(ariesSession); foreach (var interceptor in _SessionInterceptors) { try{ interceptor.SessionCreated(ariesSession); }catch (Exception ex) { LOG.Error(ex); } } //Ask for session info session.Write(new RequestClientSession()); }