Esempio n. 1
0
def OnSaveArchiveRequest(client, address, gameLogic):
    Log("[%s] : [ %s:%i ] request saveArchive." %
        (ctime(), address[0], address[1]))
    data = ReceiveDataFromClient(client, address)
    accountData = TransferProtocal_pb2.Account()
    accountData.ParseFromString(data)
    res = gameLogic.SaveArchive(accountData.account, accountData.data)
    # SendReplyCode(client, TransferProtocal_pb2.ResultType.SAVE_ARCHIVE_RES)
    # Log("[%s] : Send to [ %s:%i ] . Msg : reply code[saveArchiveRes]." % (ctime(), address[0], address[1]))
    Reply = TransferProtocal_pb2.ArchiveOpRes()
    Reply.operation = TransferProtocal_pb2.ArchiveOpRes.ADD
    if res:
        Reply.hasSucceed = True
    else:
        Reply.hasSucceed = False
    SendDataToClient(client, address, Reply.SerializeToString())
    client.recv(BufferSize)
Esempio n. 2
0
def testDeletaArchive():
    tcpCliSock = socket(AF_INET, SOCK_STREAM)
    tcpCliSock.connect(ADDR)
    request = TransferProtocal_pb2.RequestType()
    request.request = TransferProtocal_pb2.RequestType.DELETE_ARCHIVE_REQ

    data = request.SerializeToString()
    sendDataToServer(tcpCliSock, ADDR, data)

    request = TransferProtocal_pb2.Account()
    request.account = "hrhtr4"
    request.password = "******"

    sendDataToServer(tcpCliSock, ADDR, request.SerializeToString())

    data = receiveDataFromServer(tcpCliSock, ADDR)
    tcpCliSock.send("OK".encode())
    result = TransferProtocal_pb2.ArchiveOpRes()
    result.ParseFromString(data)
    ##print(str(result.hasSucceed), str(result.operation))

    tcpCliSock.close()
Esempio n. 3
0
# test

from Protocal.generate import TransferProtocal_pb2

request = TransferProtocal_pb2.RequestType()
request.request = TransferProtocal_pb2.RequestType.REGISTER_REQ
data = request.SerializeToString()

result = TransferProtocal_pb2.ResultType()
result.result = TransferProtocal_pb2.ResultType.REGISTER_RES

account = TransferProtocal_pb2.Account()
account.account = "dfsefefsf"
account.password = "******"
account.data = "gdrlgrjmijgg的距离高考家里人".encode()

registerRes = TransferProtocal_pb2.RegisterRes()
registerRes.hasSucceed = True
registerRes.error = TransferProtocal_pb2.RegisterRes.INVALIDATED_ACCOUNT

archiveOp = TransferProtocal_pb2.ArchiveOpRes()
archiveOp.hasSucceed = False
archiveOp.operation = TransferProtocal_pb2.ArchiveOpRes.ADD
archiveOp.data = "dijgim规模i然后554632".encode()