Пример #1
0
 def start(self):
     bot = FBot(listen_socks=[900, 1100], listen_accpet_callback=self.listen_accept_callback, report_status=True,
                comment="任务大脑调度")
     bot.add_listen_callbacks(901, self.protocol_state_B)
     bot.add_listen_callbacks(903, self.protocol_state_D)
     bot.add_listen_callbacks(1101, self.protocol_state_B2)
     bot.add_listen_callbacks(1103, self.protocol_state_D2)
     bot.add_listen_callbacks(1105, self.protocol_state_E2)
     bot.run()
Пример #2
0
    print("[*]Protocol State D2:PeerName={0},Value={1},Param1={2},Param2={3}".
          format(peerName, value, param1, param2))
    sendCTUnit = FBot.make_package(1104, "", "", "")
    retCTUnitArray = [sendCTUnit]
    return retCTUnitArray


def protocol_state_E2(peerName, value, param1, param2, is_last_package):
    print("[*]Protocol State E2:PeerName={0},Value={1},Param1={2},Param2={3}".
          format(peerName, value, param1, param2))
    sendCTUnit = FBot.make_package(1106, "", "", "")
    retCTUnitArray = [sendCTUnit]
    return retCTUnitArray


def listen_accept_callback(**kwargs):
    for key in kwargs:
        print(key, kwargs[key])


if __name__ == "__main__":
    bot = FBot(listen_socks=[900, 1100],
               listen_accpet_callback=listen_accept_callback,
               report_status=True,
               comment="任务大脑调度")
    bot.add_listen_callbacks(901, protocol_state_B)
    bot.add_listen_callbacks(903, protocol_state_D)
    bot.add_listen_callbacks(1101, protocol_state_B2)
    bot.add_listen_callbacks(1103, protocol_state_D2)
    bot.add_listen_callbacks(1105, protocol_state_E2)
    bot.run()
Пример #3
0
                                 is_last_package):
    print(
        "[*]Listen Request Exec Callback:PeerName={0},Value={1},Param1={2},Param2={3}"
        .format(peerName, value, param1, param2))
    sendCTUnit = FBot.make_package(OP_ACTION_BRAIN_SUB_CMD_REPLY_REQUEST_EXEC,
                                   "Do Add Task", "100", "200")
    retCTUnitArray = [sendCTUnit]
    return retCTUnitArray


#实现关于OP_ACTION_BRAIN_SUB_CMD_REPLY_EXEC_RESULT指令的回调
def listen_reply_request_exec_callback(peerName, value, param1, param2,
                                       is_last_package):
    print(
        "[*]Listen Reply Request Exec Callback:PeerName={0},Value={1},Param1={2},Param2={3}"
        .format(peerName, value, param1, param2))
    sendCTUnit = FBot.make_package(
        OP_ACTION_BRAIN_SUB_CMD_REPLY_REPLY_EXEC_RESULT, "", "", "")
    retCTUnitArray = [sendCTUnit]
    return retCTUnitArray


if __name__ == "__main__":
    bot = FBot(name="BrainA",
               listen_mode=True,
               listen_operate_id=LISTEN_SOCK_FBOT_ACTION_BRAIN_OPERATE)
    bot.add_listen_callbacks(str(OP_ACTION_BRAIN_SUB_CMD_REQUEST_EXEC),
                             listen_request_exec_callback)
    bot.add_listen_callbacks(str(OP_ACTION_BRAIN_SUB_CMD_REPLY_EXEC_RESULT),
                             listen_reply_request_exec_callback)
    bot.run()