コード例 #1
0
ファイル: connections.py プロジェクト: phvash/bello
def reply(connection, username, client_address):

    """ responsible for sending replies on behalf host machine """

    client_ip, port = client_address
    try:
        while True:
            data = connection.recv(1024)

            if data and 'dummie' in data:
                connection.sendall(username)
                break

            elif data and 'call' in data:

                call_obj = Call(vid_recv_port = 5009, vid_send_port = 5010)
                call_obj.start()

                print 'live chat started with'

                # videofeed.send_video_feed(client_ip)
    finally:
        # Clean up the connection
        if connection:
            connection.close()
コード例 #2
0
ファイル: connections.py プロジェクト: phvash/bello
def connect_host(connection_type, host='0.0.0.0', port=5098):

    """ handles all outgoing connections from the CLIENT to SERVER """

    # Create a TCP/IP socket
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    print 'connecting to %s port %s' % (host, port)
    # starts a connection with server
    sock.connect((host, port))
    # receives
    if connection_type == 'dummie':
        username = get_username(host, sock, connection_type)
        return username
    elif connection_type == 'call':
        sock.sendall(connection_type)
        # videofeed.receive_video_feed()
        call_obj = Call(client_ip = host, vid_recv_port = 5010, vid_send_port = 5009)
        call_obj.start()