Skip to content

Commit

Permalink
#2744 hook control commands
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@26890 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jul 5, 2020
1 parent 746f8f8 commit a8ee123
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
30 changes: 21 additions & 9 deletions src/xpra/client/mixins/network_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#pylint: disable-msg=E1101

from xpra import __version__ as VERSION
from xpra.util import envint, envfloat, typedict, DETACH_REQUEST, PROTOCOL_ERROR
from xpra.util import envint, envfloat, typedict, DETACH_REQUEST, PROTOCOL_ERROR, DONE
from xpra.os_util import bytestostr
from xpra.net.bytestreams import log_new_connection
from xpra.net.socket_util import create_sockets, add_listen_socket, accept_connection
from xpra.net.net_util import get_network_caps
Expand Down Expand Up @@ -133,7 +134,15 @@ def handle_new_connection(self, socktype, listener, _handle):

def process_network_packet(self, proto, packet):
log("process_network_packet: %s", packet)
if packet[0]==b"hello":
packet_type = bytestostr(packet[0])
def close():
try:
self._close_timers.pop(proto)
except KeyError:
pass
else:
proto.close()
if packet_type=="hello":
caps = typedict(packet[1])
proto.parse_remote_caps(caps)
proto.enable_compressor_from_caps(caps)
Expand All @@ -153,17 +162,20 @@ def protocol_closed():
return
elif request=="version":
proto.send_now(["hello", {"version" : VERSION}])
elif request=="command":
command = caps.strtupleget("command_request")
log("command request: %s", command)
self.idle_add(self._process_control, ["control"]+list(command))
proto.send_disconnect([DONE])
else:
log.info("request '%s' is not handled by this client", request)
proto.send_disconnect([PROTOCOL_ERROR])
elif packet_type=="connection-lost":
close()
return
else:
log.info("packet '%s' is not handled by this client", packet_type)
proto.send_disconnect([PROTOCOL_ERROR])
#make sure the connection is closed:
def close():
try:
self._close_timers.pop(proto)
except KeyError:
pass
else:
proto.close()
tid = self.timeout_add(REQUEST_TIMEOUT*1000, close)
self._close_timers[proto] = tid
2 changes: 1 addition & 1 deletion src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def _process_control(self, packet):
command = bytestostr(packet[1])
if command=="show_session_info":
args = packet[2:]
log("calling show_session_info%s on server request", args)
log("calling %s%s on server request", self.show_session_info, args)
self.show_session_info(*args)
elif command=="show_bug_report":
self.show_bug_report()
Expand Down

0 comments on commit a8ee123

Please sign in to comment.