The command handler has been completely overhauled and is actually readable now. It -might- be a little faster as well. It's not really that point in development to start micro-optimizing, so I haven't ran any benchmarks.
Our command evaluation now mirrors MUX2's. It was kind of weird before now, I'm not really sure how it got so out of order. In any case, I'm no longer ashamed of our command handler code. Hooray.
This commit is contained in:
parent
d58f4eb517
commit
66a529ba84
2 changed files with 175 additions and 101 deletions
|
|
@ -90,10 +90,24 @@ class SessionProtocol(StatefulTelnetProtocol):
|
|||
cmdhandler.handle(command)
|
||||
|
||||
def execute_cmd(self, cmdstr):
|
||||
"""
|
||||
Executes a command as this session.
|
||||
"""
|
||||
self.lineReceived(data=cmdstr)
|
||||
"""
|
||||
Executes a command as this session.
|
||||
"""
|
||||
self.lineReceived(data=cmdstr)
|
||||
|
||||
def count_command(self, silently=False):
|
||||
"""
|
||||
Hit this when the user enters a command in order to update idle timers
|
||||
and command counters. If silently is True, the public-facing idle time
|
||||
is not updated.
|
||||
"""
|
||||
# Store the timestamp of the user's last command.
|
||||
self.cmd_last = time.time()
|
||||
# Increment the user's command counter.
|
||||
self.cmd_total += 1
|
||||
if not silently:
|
||||
# Player-visible idle time, not used in idle timeout calcs.
|
||||
self.cmd_last_visible = time.time()
|
||||
|
||||
def handle_close(self):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue