Continued network mode implementation
This commit is contained in:
parent
4f5227cd82
commit
f4680cc631
4 changed files with 126 additions and 38 deletions
|
@ -19,11 +19,11 @@ class GTPSocket:
|
|||
#
|
||||
# dispatcher = {'command1': function_1, 'command_2': function_2, 'command_3': function_3}
|
||||
# gtp_socket = GTPSocket(socket)
|
||||
# GTPSocket.known_cmds.extend(dispatcher.keys())
|
||||
# GTPSocket.known_cmds = GTPSocket.known_cmds & set(dispatcher.keys())
|
||||
# gtp = gtp_socket.get()
|
||||
# if gtp.type == 'command':
|
||||
# dispatcher[gtp.command](gtp)
|
||||
known_cmds = ['protocol_version', 'name', 'version', 'known_command', 'list_commands']
|
||||
known_cmds = set(['protocol_version', 'name', 'version', 'known_command', 'list_commands'])
|
||||
|
||||
def __init__(self, socket):
|
||||
self.socket = None
|
||||
|
@ -51,12 +51,15 @@ class GTPSocket:
|
|||
# Some gtp commands should be handled internally
|
||||
if gtp.command == 'protocol_version':
|
||||
self.send_response('2', gtp.id)
|
||||
return None
|
||||
|
||||
elif gtp.command == 'name':
|
||||
self.send_response('pygo', gtp.id)
|
||||
return None
|
||||
|
||||
elif gtp.command == 'version':
|
||||
self.send_response('', gtp.id)
|
||||
return None
|
||||
|
||||
elif gtp.command == 'known_command':
|
||||
if gtp.arguments[0] in GTPSocket.known_cmds:
|
||||
|
@ -64,9 +67,14 @@ class GTPSocket:
|
|||
else:
|
||||
resp = 'false'
|
||||
self.send_response(resp, gtp.id)
|
||||
return None
|
||||
|
||||
elif gtp.command == 'list_commands':
|
||||
self.send_response(''.join(GTPSocket.known_cmds, '\n'), gtp.id)
|
||||
return None
|
||||
|
||||
else:
|
||||
return gtp
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue