xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #21: ping.patch

File ping.patch, 2.3 KB (added by Antoine Martin, 10 years ago)

patching adding latency measurement via simple ping

  • xpra/server.py

     
    12921292                self._send_new_window_packet(window)
    12931293        if self.send_cursors:
    12941294            self.send_cursor()
     1295        if True:
     1296            self.send_ping()
    12951297
    12961298    def send_hello(self, client_capabilities):
    12971299        capabilities = {}
     
    15331535        log("received sequence: %s", packet_sequence)
    15341536        self._server_source.last_client_packet_sequence = packet_sequence
    15351537
     1538    def send_ping(self):
     1539        if self._protocol and not self._protocol._closed:
     1540            self._send(["ping", long(1000.0*time.time())])
     1541            gobject.timeout_add(1000, self.send_ping)
     1542
     1543    def _process_ping_echo(self, proto, packet):
     1544        (_, ts) = packet
     1545        now = long(1000.0*time.time())
     1546        log.info("ping_echo time=%s, now=%s, ts=%s, latency=%s", time.time(), now, ts, now-ts)
     1547
    15361548    def _process_buffer_refresh(self, proto, packet):
    15371549        (_, id, _, jpeg_qual) = packet
    15381550        if self.encoding=="jpeg":
     
    15911603        "shutdown-server": _process_shutdown_server,
    15921604        "jpeg-quality": _process_jpeg_quality,
    15931605        "damage-sequence": _process_damage_sequence,
     1606        "ping_echo": _process_ping_echo,
    15941607        "buffer-refresh": _process_buffer_refresh,
    15951608        "desktop_size": _process_desktop_size,
    15961609        "encoding": _process_encoding,
  • xpra/client.py

     
    876876        log("_process_notify_close(%s)", id)
    877877        self._client_extras.close_notify(id)
    878878
     879    def _process_ping(self, packet):
     880        (_, ts) = packet
     881        log.info("ping: %s", ts)
     882        self.send(["ping_echo", ts])
     883
    879884    def _process_window_metadata(self, packet):
    880885        (_, id, metadata) = packet
    881886        window = self._id_to_window[id]
     
    918923        "bell": _process_bell,
    919924        "notify_show": _process_notify_show,
    920925        "notify_close": _process_notify_close,
     926        "ping": _process_ping,
    921927        "window-metadata": _process_window_metadata,
    922928        "configure-override-redirect": _process_configure_override_redirect,
    923929        "lost-window": _process_lost_window,