Exemplo n.º 1
0
def hangup(socket, args):
    target = socket_by_username(args[1], socket)
    if target:
        call = call_between(socket, target)
        if call:
            call.hangup()
            send_cmd_success(socket, 112)
        else:
            send_error(socket, 403)
Exemplo n.º 2
0
def send_msg(socket, args):
    """This will send the normal txt messages"""
    if args.get('user'):
        # message to user
        content = args.get('content')
        sock = socket_by_username(args.get('user'), socket)
        if sock:
            send_message(sock, inputs[socket].profile.username, content)
    else:
        # TODO: Group message
        pass
Exemplo n.º 3
0
def call(socket, args):
    target = socket_by_username(args[1], socket)
    if target:
        if not call_between(socket, target):
            if inputs[target].udp_addr:
                Call(caller=socket, target=target)
                send_cmd_success(socket, 110)
            else:
                send_error(socket, 401)
        else:
            send_error(socket, 402)
Exemplo n.º 4
0
def call(socket, args):
    target = socket_by_username(args[1], socket)
    if target and not inputs[socket].call:
        if not inputs[target].call:
            if inputs[target].udp_addr:
                Call(caller=socket, target=target)
            else:
                # Target is not ready for udp
                send_error(socket, 401)
        else:
            # TODO: target is already having a call
            pass
    else:
        # TODO: You already are having a call
        pass
Exemplo n.º 5
0
def answer(socket, args):
    def pending(socket, target):
        call = call_between(socket, target)
        if call and not call.answered:
            return call
        return False
    target = socket_by_username(args[1], socket)
    if target:
        # call = inputs[socket].call_pending(target)
        call = pending(socket, target)
        if call:
            send_cmd_success(socket, 111)
            call.answer()
        else:
            send_error(socket, 400)