Fixed a malformed call to portal_disconnect that stopped auto-disconnection from working. Also removed sessiohandler.portal_disconnect since it has no function anymore, as well as changed two AMP command chars around for better debugging (they were matching the tab- and line breaks chars before). Resolves #900.
This commit is contained in:
parent
8d672a8e9d
commit
8655f880f2
2 changed files with 7 additions and 20 deletions
|
|
@ -38,6 +38,7 @@ class DummySession(object):
|
||||||
DUMMYSESSION = DummySession()
|
DUMMYSESSION = DummySession()
|
||||||
|
|
||||||
# communication bits
|
# communication bits
|
||||||
|
# (chr(9) and chr(10) are \t and \n, so skipping them)
|
||||||
|
|
||||||
PCONN = chr(1) # portal session connect
|
PCONN = chr(1) # portal session connect
|
||||||
PDISCONN = chr(2) # portal session disconnect
|
PDISCONN = chr(2) # portal session disconnect
|
||||||
|
|
@ -47,8 +48,8 @@ SDISCONN = chr(5) # server session disconnect
|
||||||
SDISCONNALL = chr(6) # server session disconnect all
|
SDISCONNALL = chr(6) # server session disconnect all
|
||||||
SSHUTD = chr(7) # server shutdown
|
SSHUTD = chr(7) # server shutdown
|
||||||
SSYNC = chr(8) # server session sync
|
SSYNC = chr(8) # server session sync
|
||||||
SCONN = chr(9) # server creating new connection (for irc/imc2 bots etc)
|
SCONN = chr(11) # server creating new connection (for irc/imc2 bots etc)
|
||||||
PCONNSYNC = chr(10) # portal post-syncing a session
|
PCONNSYNC = chr(12) # portal post-syncing a session
|
||||||
AMP_MAXLEN = amp.MAX_VALUE_LENGTH # max allowed data length in AMP protocol (cannot be changed)
|
AMP_MAXLEN = amp.MAX_VALUE_LENGTH # max allowed data length in AMP protocol (cannot be changed)
|
||||||
|
|
||||||
BATCH_RATE = 250 # max commands/sec before switching to batch-sending
|
BATCH_RATE = 250 # max commands/sec before switching to batch-sending
|
||||||
|
|
@ -429,7 +430,7 @@ class AMPProtocol(amp.AMP):
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sessid (int): Unique Session id.
|
sessid (int): Unique Session id.
|
||||||
msg (str): Message to send over the wire.
|
text (str): Message to send over the wire.
|
||||||
kwargs (any, optional): Optional data.
|
kwargs (any, optional): Optional data.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
@ -493,7 +494,7 @@ class AMPProtocol(amp.AMP):
|
||||||
elif operation == PDISCONN: # portal_session_disconnect
|
elif operation == PDISCONN: # portal_session_disconnect
|
||||||
# session closed from portal side
|
# session closed from portal side
|
||||||
session = server_sessionhandler[sessid]
|
session = server_sessionhandler[sessid]
|
||||||
self.factory.server.sessions.portal_disconnect(session)
|
self.factory.server.sessions.disconnect(session)
|
||||||
|
|
||||||
elif operation == PSYNC: # portal_session_sync
|
elif operation == PSYNC: # portal_session_sync
|
||||||
# force a resync of sessions when portal reconnects to
|
# force a resync of sessions when portal reconnects to
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,8 @@ SDISCONN = chr(5) # server session disconnect
|
||||||
SDISCONNALL = chr(6) # server session disconnect all
|
SDISCONNALL = chr(6) # server session disconnect all
|
||||||
SSHUTD = chr(7) # server shutdown
|
SSHUTD = chr(7) # server shutdown
|
||||||
SSYNC = chr(8) # server session sync
|
SSYNC = chr(8) # server session sync
|
||||||
SCONN = chr(9) # server portal connection (for bots)
|
SCONN = chr(11) # server portal connection (for bots)
|
||||||
PCONNSYNC = chr(10) # portal post-syncing session
|
PCONNSYNC = chr(12) # portal post-syncing session
|
||||||
|
|
||||||
# i18n
|
# i18n
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
|
@ -193,20 +193,6 @@ class ServerSessionHandler(SessionHandler):
|
||||||
# protocol_flags etc)
|
# protocol_flags etc)
|
||||||
session.load_sync_data(portalsessiondata)
|
session.load_sync_data(portalsessiondata)
|
||||||
|
|
||||||
def portal_disconnect(self, sessid):
|
|
||||||
"""
|
|
||||||
Called by Portal when portal reports a closing of a session
|
|
||||||
from the portal side.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
sessid (int): Session id.
|
|
||||||
|
|
||||||
"""
|
|
||||||
session = self.get(sessid, None)
|
|
||||||
if not session:
|
|
||||||
return
|
|
||||||
self.disconnect(session)
|
|
||||||
|
|
||||||
def portal_sessions_sync(self, portalsessionsdata):
|
def portal_sessions_sync(self, portalsessionsdata):
|
||||||
"""
|
"""
|
||||||
Syncing all session ids of the portal with the ones of the
|
Syncing all session ids of the portal with the ones of the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue