Exemple #1
0
def leaveMsg(id, cmd, ignored):
    if not cmd.topic:
        cmd.topic = DefaultTopic
    return pb.ClientMsg(leave=pb.ClientLeave(id=str(id),
                                             topic=cmd.topic,
                                             unsub=cmd.unsub),
                        on_behalf_of=DefaultUser)
Exemple #2
0
def leave(topic):
    tid = next_id()
    add_future(tid, {
        'arg': topic,
        'onsuccess': lambda topicName, unused: del_subscription(topicName)
    })
    return pb.ClientMsg(leave=pb.ClientLeave(id=tid, topic=topic))
Exemple #3
0
def leaveMsg(id, topic, unsub):
    if not topic:
        topic = default_topic
    return pb.ClientMsg(leave=pb.ClientLeave(id=str(id),
                                             topic=topic,
                                             unsub=unsub),
                        on_behalf_of=default_user)
Exemple #4
0
def serialize_cmd(string, id):
    """Take string read from the command line, convert in into a protobuf message"""

    # Convert string into a dictionary
    cmd = parse_cmd(string)
    if cmd == None:
        return None

    # Process dictionary
    if cmd.cmd == "acc":
        return accMsg(id, cmd.user, cmd.scheme, cmd.secret, cmd.uname, cmd.password,
            cmd.do_login, cmd.fn, cmd.photo, cmd.private, cmd.auth, cmd.anon, cmd.tags, cmd.cred)
    elif cmd.cmd == "login":
        return loginMsg(id, cmd.scheme, cmd.secret, cmd.cred, cmd.uname, cmd.password)
    elif cmd.cmd == "sub":
        return subMsg(id, cmd.topic, cmd.fn, cmd.photo, cmd.private, cmd.auth, cmd.anon,
            cmd.mode, cmd.tags, cmd.get_query)
    elif cmd.cmd == "leave":
        return pb.ClientMsg(leave=pb.ClientLeave(id=str(id), topic=cmd.topic))
    elif cmd.cmd == "pub":
        return pb.ClientMsg(pub=pb.ClientPub(id=str(id), topic=cmd.topic, no_echo=True,
            content=json.dumps(cmd.content)))
    elif cmd.cmd == "get":
        return getMsg(id, cmd.topic, cmd.desc, cmd.sub, cmd.tags, cmd.data)
    elif cmd.cmd == "set":
        return setMsg(id, cmd.topic, cmd.user, cmd.fn, cmd.photo, cmd.public, cmd.private,
            cmd.auth, cmd.anon, cmd.mode, cmd.tags)
    elif cmd.cmd == "del":
        return delMsg(id, cmd.topic, cmd.what, cmd.param, cmd.hard)
    elif cmd.cmd == "note":
        return noteMsg(id, cmd.topic, cmd.what, cmd.seq)
    else:
        print("Unrecognized: " + cmd.cmd)
        return None