示例#1
0
文件: rfb_server.py 项目: tardyp/Xpra
 def _process_rfb_authenticated(self, proto, _packet):
     model = self._get_rfb_desktop_model()
     if not model:
         proto.close()
         return
     self.accept_protocol(proto)
     #use blocking sockets from now on:
     from xpra.net.bytestreams import set_socket_timeout
     set_socket_timeout(proto._conn, None)
     accepted, share_count, disconnected = self.handle_sharing(
         proto, share=proto.share)
     log("rfb handle sharing: accepted=%s, share count=%s, disconnected=%s",
         accepted, share_count, disconnected)
     if not accepted:
         return
     source = RFBSource(proto, self._get_rfb_desktop_model(), proto.share)
     if server_features.input_devices:
         source.keyboard_config = self.get_keyboard_config()
         self.set_keymap(source)
     self._server_sources[proto] = source
     w, h = model.get_dimensions()
     source.damage(self._window_to_id[model], model, 0, 0, w, h)
     #ugly weak dependency,
     #shadow servers need to be told to start the refresh timer:
     start_refresh = getattr(self, "start_refresh", None)
     if start_refresh:
         for wid in tuple(self._window_to_id.values()):
             start_refresh(wid)
示例#2
0
 def _process_rfb_authenticated(self, proto, _packet):
     model = self._get_rfb_desktop_model()
     if not model:
         proto.close()
         return
     self.accept_protocol(proto)
     #use blocking sockets from now on:
     set_socket_timeout(proto._conn, None)
     accepted, share_count, disconnected = self.handle_sharing(
         proto, share=proto.share)
     log("RFB handle sharing: accepted=%s, share count=%s, disconnected=%s",
         accepted, share_count, disconnected)
     if not accepted:
         return
     source = RFBSource(proto, proto.share)
     self._server_sources[proto] = source
     #continue in the UI thread:
     self.idle_add(self._accept_rfb_source, source)
示例#3
0
    def test_rfb_source(self):
        #fake protocol:
        p = AdHocStruct()
        p.send = noop
        p.queue_size = lambda: 1
        #fake window:
        window = AdHocStruct()

        def get_image(x, y, w, h):
            stride = (w + 8) * 4
            pixels = b"0" * stride * h
            return ImageWrapper(x, y, w, h, pixels, "BGRX", 24, stride, 4)

        window.get_image = get_image
        window.acknowledge_changes = noop
        for protocol in (p, None):
            s = RFBSource(protocol, True)
            assert s.get_info()
            s.get_window_info(())
            s.ping()
            s.keys_changed()
            s.set_default_keymap()
            s.send_cursor()
            s.send_server_event()
            s.update_mouse()
            s.damage(1, window, 0, 0, 1024, 768, {"polling": protocol is None})
            s.damage(1, window, 0, 0, 2, 2, {"polling": protocol is None})
            s.send_clipboard("foo")
            s.bell()
            assert not s.is_closed()
            s.close()
            #noop:
            s.damage(1, window, 0, 0, 2, 2, {"polling": protocol is None})
            assert s.is_closed()