mirror of
https://github.com/evennia/evennia.git
synced 2026-04-08 09:24:37 +02:00
Converted to Twisted from asyncore. Not positive if this is just my local machine, but it seems like this backend is a bit faster.
This commit is contained in:
parent
82f46a2b69
commit
97cf1213e6
8 changed files with 113 additions and 145 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import time
|
||||
from session import PlayerSession
|
||||
import gameconf
|
||||
|
||||
"""
|
||||
|
|
@ -8,13 +7,12 @@ Session manager, handles connected players.
|
|||
# Our list of connected sessions.
|
||||
session_list = []
|
||||
|
||||
def new_session(server, conn, addr):
|
||||
def add_session(session):
|
||||
"""
|
||||
Create and return a new session.
|
||||
Adds a session to the session list.
|
||||
"""
|
||||
session = PlayerSession(server, conn, addr)
|
||||
session_list.insert(0, session)
|
||||
return session
|
||||
print 'Sessions active:', len(get_session_list())
|
||||
|
||||
def get_session_list():
|
||||
"""
|
||||
|
|
@ -22,6 +20,13 @@ def get_session_list():
|
|||
"""
|
||||
return session_list
|
||||
|
||||
def disconnect_all_sessions():
|
||||
"""
|
||||
Cleanly disconnect all of the connected sessions.
|
||||
"""
|
||||
for sess in get_session_list():
|
||||
sess.handle_close()
|
||||
|
||||
def check_all_sessions():
|
||||
"""
|
||||
Check all currently connected sessions and see if any are dead.
|
||||
|
|
@ -38,14 +43,7 @@ def check_all_sessions():
|
|||
if (time.time() - sess.cmd_last) > idle_timeout:
|
||||
sess.msg("Idle timeout exceeded, disconnecting.")
|
||||
sess.handle_close()
|
||||
## This doesn't seem to provide an accurate indication of timed out
|
||||
## sessions.
|
||||
#if not sess.writable() or not sess.readable():
|
||||
# print 'Problematic Session:'
|
||||
# print 'Readable ', sess.readable()
|
||||
# print 'Writable ', sess.writable()
|
||||
|
||||
|
||||
|
||||
def remove_session(session):
|
||||
"""
|
||||
Removes a session from the session list.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue