コード例 #1
0
ファイル: test_protocol_base.py プロジェクト: svn2github/Xpra
class SimpleClient(object):

    def init(self, exit_cb, packets=[]):
        self.packets = packets
        sock = socket.socket(socket.AF_UNIX)
        sock.settimeout(5)
        sock.connect(TEST_SOCKFILE)
        sock.settimeout(None)
        sc = makeSocketConnection(sock, "test-client-socket")
        self.protocol = Protocol(gobject, sc, self.process_packet, None)
        self.protocol.start()
        if len(self.packets)>0:
            gobject.timeout_add(1000, self.send_packet)

    def send_packet(self):
        self.protocol.send_now(self.packets[0])
        self.packets = self.packets[1:]
        return len(self.packets)>0

    def process_packet(self, proto, packet):
        log.info("process_packet(%s, %s)", proto, packet)

    def get_packet(self, *args):
        log.info("get_packet(%s)", args)
        return None
コード例 #2
0
class SimpleClient(object):

    def init(self, exit_cb, packets=()):
        self.packets = packets
        sock = socket.socket(socket.AF_UNIX)
        sock.settimeout(5)
        sock.connect(TEST_SOCKFILE)
        sock.settimeout(None)
        sc = makeSocketConnection(sock, "test-client-socket")
        self.protocol = Protocol(glib, sc, self.process_packet, None)
        self.protocol.start()
        if len(self.packets)>0:
            gobject.timeout_add(1000, self.send_packet)

    def send_packet(self):
        self.protocol.send_now(self.packets[0])
        self.packets = self.packets[1:]
        return len(self.packets)>0

    def process_packet(self, proto, packet):
        log.info("process_packet(%s, %s)", proto, packet)

    def get_packet(self, *args):
        log.info("get_packet(%s)", args)
        return None
コード例 #3
0
ファイル: udp_protocol.py プロジェクト: DiGuoZhiMeng/Xpra
 def _send_async(self, packet, sync=False, fail_cb=None):
     """ used by send_control to bypass the regular queuing functions,
         and force enable synchronous=False
     """
     #log("_send_async(%s, %s) encoder=%s, compressor=%s", packet, sync, self._encoder, self._compress)
     log("_send_async(%s, %s)", packet, sync)
     chunks = self.encode(packet)
     if len(chunks) > 1:
         return Protocol.send_now(self, packet)
     proto_flags, index, level, data = chunks[0]
     from xpra.net.header import pack_header
     payload_size = len(data)
     header_and_data = pack_header(proto_flags, level, index,
                                   payload_size) + data
     with self._write_lock:
         if self._write_thread is None:
             self.start_write_thread()
         self._write_queue.put((header_and_data, None, None, fail_cb, sync))