mirror of
https://github.com/evennia/evennia.git
synced 2026-03-21 15:26:30 +01:00
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.
|
||||
"""
|
||||
session_mgr.add_session(self)
|
||||
self.game_connect_screen()
|
||||
self.prep_session()
|
||||
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):
|
||||
"""
|
||||
|
|
@ -61,7 +60,7 @@ class SessionProtocol(StatefulTelnetProtocol):
|
|||
Execute this when a client abruplty loses their connection.
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
|
|
@ -96,7 +95,6 @@ class SessionProtocol(StatefulTelnetProtocol):
|
|||
self.disconnectClient()
|
||||
self.logged_in = False
|
||||
session_mgr.remove_session(self)
|
||||
print 'Sessions active:', len(session_mgr.get_session_list())
|
||||
|
||||
def get_pobject(self):
|
||||
"""
|
||||
|
|
@ -161,7 +159,7 @@ class SessionProtocol(StatefulTelnetProtocol):
|
|||
String representation of the user session class. We use
|
||||
this a lot in the server logs and stuff.
|
||||
"""
|
||||
if self.logged_in:
|
||||
if self.is_loggedin():
|
||||
symbol = '#'
|
||||
else:
|
||||
symbol = '?'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import time
|
||||
import gameconf
|
||||
import functions_general
|
||||
|
||||
"""
|
||||
Session manager, handles connected players.
|
||||
|
|
@ -12,7 +13,7 @@ def add_session(session):
|
|||
Adds a session to the session list.
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
|
|
@ -42,7 +43,7 @@ def check_all_sessions():
|
|||
if idle_timeout <= 0:
|
||||
return
|
||||
|
||||
for sess in get_session_list():
|
||||
for sess in get_session_list(return_unlogged=True):
|
||||
if (time.time() - sess.cmd_last) > idle_timeout:
|
||||
sess.msg("Idle timeout exceeded, disconnecting.")
|
||||
sess.handle_close()
|
||||
|
|
@ -52,6 +53,7 @@ def remove_session(session):
|
|||
Removes a session from the session list.
|
||||
"""
|
||||
session_list.remove(session)
|
||||
print 'Sessions active:', len(get_session_list())
|
||||
|
||||
def session_from_object(targobject):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue