More graceful handling of session creation/destruction.
This commit is contained in:
parent
152271132d
commit
5384bed052
2 changed files with 8 additions and 8 deletions
10
session.py
10
session.py
|
|
@ -21,11 +21,10 @@ class SessionProtocol(StatefulTelnetProtocol):
|
||||||
"""
|
"""
|
||||||
What to do when we get a connection.
|
What to do when we get a connection.
|
||||||
"""
|
"""
|
||||||
session_mgr.add_session(self)
|
|
||||||
self.game_connect_screen()
|
|
||||||
self.prep_session()
|
self.prep_session()
|
||||||
functions_general.log_infomsg('Connection: %s' % (self,))
|
functions_general.log_infomsg('Connection: %s' % (self,))
|
||||||
functions_general.log_infomsg('Sessions active: %d' % (len(session_mgr.get_session_list()),))
|
session_mgr.add_session(self)
|
||||||
|
self.game_connect_screen()
|
||||||
|
|
||||||
def getClientAddress(self):
|
def getClientAddress(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -61,7 +60,7 @@ class SessionProtocol(StatefulTelnetProtocol):
|
||||||
Execute this when a client abruplty loses their connection.
|
Execute this when a client abruplty loses their connection.
|
||||||
"""
|
"""
|
||||||
functions_general.log_infomsg('Disconnect: %s' % (self,))
|
functions_general.log_infomsg('Disconnect: %s' % (self,))
|
||||||
functions_general.log_infomsg('Sessions active: %d' % (len(session_mgr.get_session_list()),))
|
self.handle_close()
|
||||||
|
|
||||||
def load_user_channels(self):
|
def load_user_channels(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -96,7 +95,6 @@ class SessionProtocol(StatefulTelnetProtocol):
|
||||||
self.disconnectClient()
|
self.disconnectClient()
|
||||||
self.logged_in = False
|
self.logged_in = False
|
||||||
session_mgr.remove_session(self)
|
session_mgr.remove_session(self)
|
||||||
print 'Sessions active:', len(session_mgr.get_session_list())
|
|
||||||
|
|
||||||
def get_pobject(self):
|
def get_pobject(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -161,7 +159,7 @@ class SessionProtocol(StatefulTelnetProtocol):
|
||||||
String representation of the user session class. We use
|
String representation of the user session class. We use
|
||||||
this a lot in the server logs and stuff.
|
this a lot in the server logs and stuff.
|
||||||
"""
|
"""
|
||||||
if self.logged_in:
|
if self.is_loggedin():
|
||||||
symbol = '#'
|
symbol = '#'
|
||||||
else:
|
else:
|
||||||
symbol = '?'
|
symbol = '?'
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import time
|
import time
|
||||||
import gameconf
|
import gameconf
|
||||||
|
import functions_general
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Session manager, handles connected players.
|
Session manager, handles connected players.
|
||||||
|
|
@ -12,7 +13,7 @@ def add_session(session):
|
||||||
Adds a session to the session list.
|
Adds a session to the session list.
|
||||||
"""
|
"""
|
||||||
session_list.insert(0, session)
|
session_list.insert(0, session)
|
||||||
print 'Sessions active:', len(get_session_list())
|
functions_general.log_infomsg('Sessions active: %d' % (len(get_session_list(return_unlogged=True),)))
|
||||||
|
|
||||||
def get_session_list(return_unlogged=False):
|
def get_session_list(return_unlogged=False):
|
||||||
"""
|
"""
|
||||||
|
|
@ -42,7 +43,7 @@ def check_all_sessions():
|
||||||
if idle_timeout <= 0:
|
if idle_timeout <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
for sess in get_session_list():
|
for sess in get_session_list(return_unlogged=True):
|
||||||
if (time.time() - sess.cmd_last) > idle_timeout:
|
if (time.time() - sess.cmd_last) > idle_timeout:
|
||||||
sess.msg("Idle timeout exceeded, disconnecting.")
|
sess.msg("Idle timeout exceeded, disconnecting.")
|
||||||
sess.handle_close()
|
sess.handle_close()
|
||||||
|
|
@ -52,6 +53,7 @@ def remove_session(session):
|
||||||
Removes a session from the session list.
|
Removes a session from the session list.
|
||||||
"""
|
"""
|
||||||
session_list.remove(session)
|
session_list.remove(session)
|
||||||
|
print 'Sessions active:', len(get_session_list())
|
||||||
|
|
||||||
def session_from_object(targobject):
|
def session_from_object(targobject):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue