Exemplo n.º 1
0
def tube_incoming_cb(tube, tube_conn, loop):
    tube_conn.connect('closed', tube_conn_closed)

    contact = tube_conn.get_contact();

    print "Got IOStream from", contact.get_identifier()

    conn = tube_conn.get_socket_connection();

    # g_input_stream_read() can't be used from Python so we use the more
    # binding friendly GDataInputStream
    in_stream = Gio.DataInputStream (base_stream=conn.get_input_stream())
    out_stream = conn.get_output_stream()

    buf, len = in_stream.read_line_utf8(None)
    print "Received:", buf

    print "Sending: Pong"
    out_stream.write("Pong\n", None)

    tube.close_async(channel_close_cb, contact)
Exemplo n.º 2
0
        tube_conn = tube.accept_finish(result)
    except GObject.GError, e:
        print "Failed to accept tube: %s" % e
        sys.exit(1)

    tube_conn.connect('closed', tube_conn_closed)

    contact = tube_conn.get_contact()

    print "Got IOStream to", contact.get_identifier()

    conn = tube_conn.get_socket_connection()

    # g_input_stream_read() can't be used from Python so we use the more
    # binding friendly GDataInputStream
    in_stream = Gio.DataInputStream(base_stream=conn.get_input_stream())
    out_stream = conn.get_output_stream()

    print "Sending: Ping"
    out_stream.write("Ping\n", None)

    buf, len = in_stream.read_line_utf8(None)
    print "Received:", buf


def tube_invalidated_cb(tube, domain, code, message, loop):
    print "tube has been invalidated:", message
    loop.quit()


def handle_channels_cb(handler, account, connection, channels, requests,