示例#1
0
def test_create_join():
    idA, handle, A = yield from core.client()
    idB, handle, B = yield from core.client()
    clan = core.rndstr()
    yield from core.send(A, "clan.create", clan, "Test")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.create"
    assert rs["args"][0] == True
    clan_id = rs["args"][1]
    yield from core.send(B, "clan.join", clan_id)
    rs = yield from core.recv(B)
    assert rs["name"] == "clan.join"
    assert rs["args"][0] == True
    yield from core.send(A, "clan.members")
    rs = yield from core.recv(A)
    members = {i[0]:i for i in rs["args"][0]["members"]}
    assert idB in members
    assert members[idB][2] == "Pending"
    assert members[idB][3] == False
    yield from core.send(A, "clan.setmembertype", idB, "Member")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.setmembertype"
    assert rs["args"][0] == idB
    assert rs["args"][1] == "Member"
    assert rs["args"][2] == True
    yield from core.send(B, "clan.members")
    rs = yield from core.recv(B)
    members = {i[0]:i for i in rs["args"][0]["members"]}
    assert idB in members
    assert members[idB][2] == "Member", members
示例#2
0
def process_line(l):
    args = l.split()
    cmd = args[0]
    if cmd == 'status':
        return core.status()

    elif cmd == 'server':
        channel = args[1]
        addr = args[2]
        port = int(args[3])
        ret = core.server(channel, (addr, port))
        core.save()
        return ret

    elif cmd == 'client':
        channel = args[1]
        try:
            port = int(args[2])
        except IndexError:
            port = None

        ret = core.client(channel, port)
        core.save()
        return ret

    elif cmd == 'kill':
        id = int(args[1])
        ret = core.kill(id)
        core.save()
        return ret

    assert False
示例#3
0
def process_line(l):
    args = l.split()
    cmd = args[0]
    if cmd == 'status':
        return core.status()

    elif cmd == 'server':
        channel = args[1]
        addr = args[2]
        port = int(args[3])
        ret = core.server(channel, (addr, port))
        core.save()
        return ret

    elif cmd == 'client':
        channel = args[1]
        try:
            port = int(args[2])
        except IndexError:
            port = None

        ret = core.client(channel, port)
        core.save()
        return ret

    elif cmd == 'kill':
        id = int(args[1])
        ret = core.kill(id)
        core.save()
        return ret

    assert False
示例#4
0
文件: talkd.py 项目: 321core/STALK
def process_line(line: bytes):
    line: str = line.decode()
    args: Sequence[str] = line.split()

    cmd = args[0]

    if cmd == 'status':
        return core.status()

    elif cmd == 'server':
        channel = args[1]
        addr = args[2]
        port = int(args[3])
        ret = core.server(channel, (addr, port))
        core.save()
        return ret

    elif cmd == 'client':
        channel = args[1]
        try:
            port = int(args[2])
        except IndexError:
            port = None

        ret = core.client(channel, port)
        core.save()
        return ret

    elif cmd == 'kill':
        pid = int(args[1])
        ret = core.kill(pid)
        core.save()
        return ret

    assert False
示例#5
0
def test_list():
    id, handle, A = yield from core.client()
    clan = core.rndstr()
    yield from core.send(A, "clan.create", clan, "Test")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.create"
    assert rs["args"][0] == True
    yield from core.send(A, "clan.list")
    rs = yield from core.recv(A)
    assert rs["name"] == "clan.list"
    assert type(rs["args"][0]) == type([])
示例#6
0
def client():
    channel = str(request.args.get('channel'))

    try:
        port = int(request.args.get('port'))
    except TypeError:
        port = None

    ret = json.loads(core.client(channel, port))
    if isinstance(ret, (str, unicode)):
        return json.dumps({'code': 'failure', 'message': ret})

    return json.dumps({'code': 'success', 'port': ret})
示例#7
0
def client():
    channel = str(request.args.get('channel'))

    try:
        port = int(request.args.get('port'))
    except TypeError:
        port = None

    ret = json.loads(core.client(channel, port))
    if isinstance(ret, (str, unicode)):
        return json.dumps({'code': 'failure', 'message': ret})

    return json.dumps({'code': 'success', 'port': ret})