Suggested fix for #1231 + whitespace/docstring
This commit is contained in:
parent
657b3585f8
commit
1b24bacc12
1 changed files with 18 additions and 17 deletions
|
|
@ -28,9 +28,11 @@ _CONNECTION_QUEUE = deque()
|
||||||
|
|
||||||
DUMMYSESSION = namedtuple('DummySession', ['sessid'])(0)
|
DUMMYSESSION = namedtuple('DummySession', ['sessid'])(0)
|
||||||
|
|
||||||
#------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
# Portal-SessionHandler class
|
# Portal-SessionHandler class
|
||||||
#------------------------------------------------------------
|
# -------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
class PortalSessionHandler(SessionHandler):
|
class PortalSessionHandler(SessionHandler):
|
||||||
"""
|
"""
|
||||||
This object holds the sessions connected to the portal at any time.
|
This object holds the sessions connected to the portal at any time.
|
||||||
|
|
@ -176,8 +178,7 @@ class PortalSessionHandler(SessionHandler):
|
||||||
del self[session.sessid]
|
del self[session.sessid]
|
||||||
|
|
||||||
# Tell the Server to disconnect its version of the Session as well.
|
# Tell the Server to disconnect its version of the Session as well.
|
||||||
self.portal.amp_protocol.send_AdminPortal2Server(session,
|
self.portal.amp_protocol.send_AdminPortal2Server(session, operation=PDISCONN)
|
||||||
operation=PDISCONN)
|
|
||||||
|
|
||||||
def disconnect_all(self):
|
def disconnect_all(self):
|
||||||
"""
|
"""
|
||||||
|
|
@ -233,8 +234,8 @@ class PortalSessionHandler(SessionHandler):
|
||||||
Called by server to force a disconnect by sessid.
|
Called by server to force a disconnect by sessid.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sessid (int): Session id to disconnect.
|
session (portalsession): Session to disconnect.
|
||||||
reason (str, optional): Motivation for disconect.
|
reason (str, optional): Motivation for disconnect.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if session:
|
if session:
|
||||||
|
|
@ -352,8 +353,8 @@ class PortalSessionHandler(SessionHandler):
|
||||||
Data is serialized before passed on.
|
Data is serialized before passed on.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#from evennia.server.profiling.timetrace import timetrace
|
# from evennia.server.profiling.timetrace import timetrace # DEBUG
|
||||||
#text = timetrace(text, "portalsessionhandler.data_in")
|
# text = timetrace(text, "portalsessionhandler.data_in") # DEBUG
|
||||||
try:
|
try:
|
||||||
text = kwargs['text']
|
text = kwargs['text']
|
||||||
if (_MAX_CHAR_LIMIT > 0) and len(text) > _MAX_CHAR_LIMIT:
|
if (_MAX_CHAR_LIMIT > 0) and len(text) > _MAX_CHAR_LIMIT:
|
||||||
|
|
@ -367,10 +368,10 @@ class PortalSessionHandler(SessionHandler):
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if self.command_counter > _MAX_COMMAND_RATE > 0:
|
if self.command_counter > _MAX_COMMAND_RATE > 0:
|
||||||
# data throttle (anti DoS measure)
|
# data throttle (anti DoS measure)
|
||||||
dT = now - self.command_counter_reset
|
delta_time = now - self.command_counter_reset
|
||||||
self.command_counter = 0
|
self.command_counter = 0
|
||||||
self.command_counter_reset = now
|
self.command_counter_reset = now
|
||||||
self.command_overflow = dT < 1.0
|
self.command_overflow = delta_time < 1.0
|
||||||
if self.command_overflow:
|
if self.command_overflow:
|
||||||
reactor.callLater(1.0, self.data_in, None)
|
reactor.callLater(1.0, self.data_in, None)
|
||||||
if self.command_overflow:
|
if self.command_overflow:
|
||||||
|
|
@ -405,8 +406,8 @@ class PortalSessionHandler(SessionHandler):
|
||||||
method exixts, it sends the data to a method send_default.
|
method exixts, it sends the data to a method send_default.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
#from evennia.server.profiling.timetrace import timetrace
|
# from evennia.server.profiling.timetrace import timetrace # DEBUG
|
||||||
#text = timetrace(text, "portalsessionhandler.data_out")
|
# text = timetrace(text, "portalsessionhandler.data_out") # DEBUG
|
||||||
|
|
||||||
# distribute outgoing data to the correct session methods.
|
# distribute outgoing data to the correct session methods.
|
||||||
if session:
|
if session:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue