Suggested fix for #1231 + whitespace/docstring

This commit is contained in:
BlauFeuer 2017-02-23 15:56:27 -05:00 committed by Griatch
parent 657b3585f8
commit 1b24bacc12

View file

@ -28,9 +28,11 @@ _CONNECTION_QUEUE = deque()
DUMMYSESSION = namedtuple('DummySession', ['sessid'])(0)
#------------------------------------------------------------
# -------------------------------------------------------------
# Portal-SessionHandler class
#------------------------------------------------------------
# -------------------------------------------------------------
class PortalSessionHandler(SessionHandler):
"""
This object holds the sessions connected to the portal at any time.
@ -176,8 +178,7 @@ class PortalSessionHandler(SessionHandler):
del self[session.sessid]
# Tell the Server to disconnect its version of the Session as well.
self.portal.amp_protocol.send_AdminPortal2Server(session,
operation=PDISCONN)
self.portal.amp_protocol.send_AdminPortal2Server(session, operation=PDISCONN)
def disconnect_all(self):
"""
@ -233,8 +234,8 @@ class PortalSessionHandler(SessionHandler):
Called by server to force a disconnect by sessid.
Args:
sessid (int): Session id to disconnect.
reason (str, optional): Motivation for disconect.
session (portalsession): Session to disconnect.
reason (str, optional): Motivation for disconnect.
"""
if session:
@ -352,8 +353,8 @@ class PortalSessionHandler(SessionHandler):
Data is serialized before passed on.
"""
#from evennia.server.profiling.timetrace import timetrace
#text = timetrace(text, "portalsessionhandler.data_in")
# from evennia.server.profiling.timetrace import timetrace # DEBUG
# text = timetrace(text, "portalsessionhandler.data_in") # DEBUG
try:
text = kwargs['text']
if (_MAX_CHAR_LIMIT > 0) and len(text) > _MAX_CHAR_LIMIT:
@ -367,10 +368,10 @@ class PortalSessionHandler(SessionHandler):
now = time.time()
if self.command_counter > _MAX_COMMAND_RATE > 0:
# 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_reset = now
self.command_overflow = dT < 1.0
self.command_overflow = delta_time < 1.0
if self.command_overflow:
reactor.callLater(1.0, self.data_in, None)
if self.command_overflow:
@ -405,8 +406,8 @@ class PortalSessionHandler(SessionHandler):
method exixts, it sends the data to a method send_default.
"""
#from evennia.server.profiling.timetrace import timetrace
#text = timetrace(text, "portalsessionhandler.data_out")
# from evennia.server.profiling.timetrace import timetrace # DEBUG
# text = timetrace(text, "portalsessionhandler.data_out") # DEBUG
# distribute outgoing data to the correct session methods.
if session: