Refactoring to go with the fixed AMP structure and methods.

This commit is contained in:
Griatch 2015-09-21 16:50:05 +02:00
parent d553c46ba5
commit 1d17302d16
6 changed files with 30 additions and 28 deletions

View file

@ -425,9 +425,6 @@ class DefaultObject(ObjectDB):
All extra kwargs will be passed on to the protocol.
"""
from evennia.server.profiling.timetrace import timetrace
text = timetrace(text, "Object.msg")
text = to_str(text, force_string=True) if text != None else ""
if from_obj:
# call hook

View file

@ -255,8 +255,9 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
kwargs (any): Options from the protocol.
"""
from evennia.server.profiling.timetrace import timetrace
text = timetrace(text, "telnet.data_in")
#from evennia.server.profiling.timetrace import timetrace
#text = timetrace(text, "telnet.data_in")
self.sessionhandler.data_in(self, text=text, **kwargs)
def data_out(self, text=None, **kwargs):
@ -291,8 +292,11 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, Session):
are given.
"""
from evennia.server.profiling.timetrace import timetrace
text = timetrace(text, "telnet.data_out", final=True)
## profiling, debugging
#if text.startswith("TEST_MESSAGE"): 1/0
#from evennia.server.profiling.timetrace import timetrace
#text = timetrace(text, "telnet.data_out", final=True)
try:
text = utils.to_str(text if text else "", encoding=self.encoding)
except Exception, e:

View file

@ -32,7 +32,7 @@ def timetrace(message, idstring, tracemessage="TEST_MESSAGE", final=False):
print "** timetrace (%s): dT=%fs, total=%fs." % (idstring, t1-tlast, t1-t0)
if final:
message = "%s (total %f)" % (tracemessage, t1-t0)
message = " **** %s (total %f) **** " % (tracemessage, t1-t0)
else:
message = "%s %f %f" % (tracemessage, t1, t0)
return message

View file

@ -228,8 +228,8 @@ class ServerSession(Session):
kwargs (any): Other parameters from the protocol.
"""
from evennia.server.profiling.timetrace import timetrace
text = timetrace(text, "ServerSession.data_in")
#from evennia.server.profiling.timetrace import timetrace
#text = timetrace(text, "ServerSession.data_in")
#explicitly check for None since text can be an empty string, which is
#also valid
@ -263,8 +263,8 @@ class ServerSession(Session):
kwargs (any): Other parameters to the protocol.
"""
from evennia.server.profiling.timetrace import timetrace
text = timetrace(text, "ServerSession.data_out")
#from evennia.server.profiling.timetrace import timetrace
#text = timetrace(text, "ServerSession.data_out")
text = text if text else ""
if _INLINEFUNC_ENABLED and not "raw" in kwargs:

View file

@ -284,16 +284,16 @@ class ServerSessionHandler(SessionHandler):
"""
data = {"protocol_path":protocol_path,
"config":configdict}
self.server.amp_protocol.call_remote_PortalAdmin(0,
operation=SCONN,
data=data)
self.server.amp_protocol.send_AdminServer2Portal(0,
operation=SCONN,
data=data)
def portal_shutdown(self):
"""
Called by server when shutting down the portal.
"""
self.server.amp_protocol.call_remote_PortalAdmin(0,
self.server.amp_protocol.send_AdminServer2Portal(0,
operation=SSHUTD,
data="")
@ -343,7 +343,7 @@ class ServerSessionHandler(SessionHandler):
# sync the portal to the session
sessdata = {"logged_in": True}
if not testmode:
self.server.amp_protocol.call_remote_PortalAdmin(session.sessid,
self.server.amp_protocol.send_AdminServer2Portal(session.sessid,
operation=SLOGIN,
data=sessdata)
player.at_post_login(sessid=session.sessid)
@ -373,7 +373,7 @@ class ServerSessionHandler(SessionHandler):
sessid = session.sessid
del self.sessions[sessid]
# inform portal that session should be closed.
self.server.amp_protocol.call_remote_PortalAdmin(sessid,
self.server.amp_protocol.send_AdminServer2Portal(sessid,
operation=SDISCONN,
data=reason)
@ -384,7 +384,7 @@ class ServerSessionHandler(SessionHandler):
"""
sessdata = self.get_all_sync_data()
return self.server.amp_protocol.call_remote_PortalAdmin(0,
return self.server.amp_protocol.send_AdminServer2Portal(0,
operation=SSYNC,
data=sessdata)
@ -400,7 +400,7 @@ class ServerSessionHandler(SessionHandler):
for session in self.sessions:
del session
# tell portal to disconnect all sessions
self.server.amp_protocol.call_remote_PortalAdmin(0,
self.server.amp_protocol.send_AdminServer2Portal(0,
operation=SDISCONNALL,
data=reason)
@ -555,8 +555,9 @@ class ServerSessionHandler(SessionHandler):
Useful for connection handling messages.
"""
from evennia.server.profiling.timetrace import timetrace
text = timetrace(text, "ServerSessionHandler.data_out")
#from evennia.server.profiling.timetrace import timetrace
#text = timetrace(text, "ServerSessionHandler.data_out")
sessions = make_iter(session)
session = sessions[0]
text = text and to_str(to_unicode(text), encoding=session.encoding)
@ -584,9 +585,9 @@ class ServerSessionHandler(SessionHandler):
# send to all found sessions
for session in sessions:
self.server.amp_protocol.call_remote_MsgServer2Portal(sessid=session.sessid,
msg=text,
data=kwargs)
self.server.amp_protocol.send_MsgServer2Portal(sessid=session.sessid,
msg=text,
data=kwargs)
def data_in(self, sessid, text="", **kwargs):
"""
@ -601,8 +602,8 @@ class ServerSessionHandler(SessionHandler):
kwargs (any): Other data from protocol.
"""
from evennia.server.profiling.timetrace import timetrace
text = timetrace(text, "ServerSessionHandler.data_in")
#from evennia.server.profiling.timetrace import timetrace
#text = timetrace(text, "ServerSessionHandler.data_in")
session = self.sessions.get(sessid, None)
if session:
text = text and to_unicode(strip_control_sequences(text), encoding=session.encoding)

View file

@ -183,7 +183,7 @@ IDMAPPER_CACHE_MAXSIZE = 200 # (MB)
# accept, as a DoS countermeasure. If the rate exceeds this number, incoming
# connections will be queued to this rate, so none will be lost.
# Must be set to a value > 0.
MAX_CONNECTION_RATE = 5
MAX_CONNECTION_RATE = 2
# Determine how many commands per second a given Session is allowed
# to send to the Portal via a connected protocol. Too high rate will
# drop the command and echo a warning. Note that this will also cap