本文整理汇总了Python中thrift.TSerialization.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Python TSerialization.deserialize方法的具体用法?Python TSerialization.deserialize怎么用?Python TSerialization.deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thrift.TSerialization
的用法示例。
在下文中一共展示了TSerialization.deserialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: playing_guild_on_event_skill_attack_hit
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_guild_on_event_skill_attack_hit(message_type, channel, channel_type, serialize):
# 事件消息
message = ccevent.skill.ttypes.EventSkillAttackHit()
# 反序列化
TSerialization.deserialize(message, serialize)
if message.dest_type_ != ccentity.entity.ttypes.EntityType.TYPE_NPC:
return
if message.type_ != ccentity.entity.ttypes.EntityType.TYPE_ACTOR:
return
if message.hurt_type_ != ccentity.skill.ttypes.SkillHurtType.PHYSICS_ATTACK and \
message.hurt_type_ != ccentity.skill.ttypes.SkillHurtType.MAGIC_ATTACK and \
message.hurt_type_ != ccentity.skill.ttypes.SkillHurtType.REDUCE_HP:
return
# 获取玩家所在副本对象
playing = guild_types.PlayingManager.get_actor_playing(message.id_)
if playing is None:
proxy.Logging.error("[guild] PlayingManager.get_actor_playing(%d) failed" % message.id_)
return
# 获取副本玩家对象
actor = playing.get_actor(message.id_)
if actor is None:
proxy.Logging.error("[guild] playing.get_actor(%d) failed" % message.id_)
return
# 增加伤害
actor.add_damage(message.value_)
# 同步伤害排行
playing.broadcast_damage_ranking()
示例2: playing_idol_on_event_playing_actor_leave
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_idol_on_event_playing_actor_leave(message_type, channel, channel_type, serialize):
# 获取事件交互代理
communicator_proxy = variable_table.get_variable(ccvariable.ttypes.Variable.COMMUNICATOR_PROXY)
# 事件消息
message = ccevent.playing.ttypes.EventPlayingActorLeave()
# 反序列化
TSerialization.deserialize(message, serialize)
# 取消关注玩家杀死NPC事件、角色被杀死事件
communicator_proxy.unfollow(ccevent.ttypes.EventType.EVENT_ROLE_KILLED, \
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \
"playing_idol_on_event_actor_killed")
communicator_proxy.unfollow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC, \
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR, \
"playing_idol_on_event_actor_kill_npc")
communicator_proxy.unfollow(ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_REQUEST_COMPLETE,\
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\
"playing_idol_on_event_playing_actor_request_complete")
# 副本管理器中删除玩家对象
idol_types.PlayingManager.remove_actor(message.actor_)
log.log_debug("玩家(%d) 离开 idol副本(id=%d,template=%d)" % \
(message.actor_, message.playing_, message.template_))
示例3: playing_soul_on_event_playing_actor_enter
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_soul_on_event_playing_actor_enter(message_type, channel, channel_type, serialize):
# 事件消息
message = ccevent.playing.ttypes.EventPlayingActorEnter()
TSerialization.deserialize(message, serialize)
# 关注玩家杀死NPC事件、请求完成副本事件
proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,\
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\
"playing_soul_on_event_actor_kill_npc")
playing = soul_types.PlayingManager.get(message.playing_)
if playing == None:
return None
actor = playing.get_actor(message.actor_)
if actor == None:
actor = soul_types.Actor(message.actor_)
playing.add_actor(actor)
# 副本管理器中建立一个玩家ID和副本ID的映射关系
soul_types.PlayingManager.add_actor(message.actor_, message.playing_)
now = time.time()
# 请求初始化玩家
request = ccrequest.playing.ttypes.RequestPlayingInitializeActor()
request.actor_ = message.actor_
request.spend_time_ = now - playing.get_start_time()
request.datas_ = []
request.scores_ = []
# 发送请求
proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR,\
request)
proxy.Logging.debug("[soul] actor(%d) enter into playing" % message.actor_)
示例4: playing_unreal_soul_on_event_playing_actor_enter
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_unreal_soul_on_event_playing_actor_enter(message_type, channel, channel_type, serialize):
message = ccevent.playing.ttypes.EventPlayingActorEnter()
TSerialization.deserialize(message, serialize)
proxy.Communicator.follow(
ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,
message.actor_,
ccevent.ttypes.ChannelType.CHANNEL_ACTOR,
"playing_unreal_soul_on_event_actor_kill_npc",
)
playing = unreal_soul_types.PlayingManager.get(message.playing_)
if playing == None:
proxy.Logging.error("[unreal_soul] PlayingManager.get(%d) failed." % message.playing_)
return None
actor = playing.get_actor(message.actor_)
if actor == None:
actor = unreal_soul_types.Actor(message.actor_)
playing.add_actor(actor)
increase_actor_playing_complete(message.actor_, playing.template_)
actor.set_leave(False)
unreal_soul_types.PlayingManager.add_actor(message.actor_, message.playing_)
now = time.time()
# 初始化玩家
request = ccrequest.playing.ttypes.RequestPlayingInitializeActor()
request.actor_ = message.actor_
request.spend_time_ = now - playing.start_time_
request.datas_ = []
request.scores_ = []
proxy.Request.request(ccrequest.ttypes.RequestType.REQUEST_PLAYING_INITIALIZE_ACTOR, request)
示例5: playing_team_on_event_playing_create
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_team_on_event_playing_create(message_type, channel, channel_type, serialize):
# 事件消息
message = ccevent.playing.ttypes.EventPlayingCreate()
TSerialization.deserialize(message, serialize)
playing_config = team_types.Config.get(message.template_)
if playing_config == None:
proxy.Logging.error("[team] team_types.Config.get(%d) failed." % message.template_)
return None
playing = team_types.Playing(message.playing_, message.template_, message.scene_)
team_types.PlayingManager.add(playing)
if playing_config.summon_next_npc(message.scene_, playing.get_next_pos()) == False:
proxy.Logging.error("[team] playing_config.summon_next_npc(%d) failed." % message.scene_)
return None
playing.next_pos()
proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_ENTER,\
message.template_, ccevent.ttypes.ChannelType.CHANNEL_PLAYING,\
"playing_team_on_event_playing_actor_enter")
proxy.Communicator.follow(ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_LEAVE,\
message.template_, ccevent.ttypes.ChannelType.CHANNEL_PLAYING,\
"playing_team_on_event_playing_actor_leave")
# 定时器,副本时间
proxy.Timer.add(message.playing_, playing_config.get_playing_time() * 1000, 1,\
"playing_team_on_timer_playing")
proxy.Timer.add(message.playing_, 2000, -1, "playing_team_on_timer_sync_ranking")
proxy.Logging.debug("[team] playing(%d,%d,%d) create"\
% (message.playing_, message.template_, message.scene_))
示例6: playing_team_on_event_playing_actor_leave
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_team_on_event_playing_actor_leave(message_type, channel, channel_type, serialize):
# 事件消息
message = ccevent.playing.ttypes.EventPlayingActorLeave()
TSerialization.deserialize(message, serialize)
# 取消关注玩家杀死NPC事件
proxy.Communicator.unfollow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,\
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\
"playing_team_on_event_actor_kill_npc")
proxy.Communicator.unfollow(ccevent.ttypes.EventType.EVENT_SKILL_ATTACK_HIT,\
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\
"playing_team_on_event_skill_attack_hit")
playing = team_types.PlayingManager.get(message.playing_)
if playing == None:
return None
actor = playing.get_actor(message.actor_)
if actor == None:
proxy.Logging.debug("[team] playing.get_actor(%d) failed." % message.actor_)
return None
actor.set_leave(True)
# 副本管理器中删除玩家ID和副本ID的映射关系
team_types.PlayingManager.remove_actor(message.actor_)
proxy.Logging.debug("[team] actor(%d) leave from playing" % message.actor_)
示例7: playing_guild_on_event_playing_actor_leave
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_guild_on_event_playing_actor_leave(message_type, channel, channel_type, serialize):
# 事件消息
message = ccevent.playing.ttypes.EventPlayingActorLeave()
# 反序列化
TSerialization.deserialize(message, serialize)
# 取消关注事件
proxy.Communicator.unfollow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,
"playing_guild_on_event_actor_kill_npc")
proxy.Communicator.unfollow(ccevent.ttypes.EventType.EVENT_SKILL_ATTACK_HIT,
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,
"playing_guild_on_event_skill_attack_hit")
# 获取副本对象
playing = guild_types.PlayingManager.get(message.playing_)
if playing is None:
proxy.Logging.error("[guild] PlayingManager.get(%d) failed" % message.playing_)
return
# 获取副本玩家对象
actor = playing.get_actor(message.actor_)
if actor is None:
proxy.Logging.error("[guild] playing.get_actor(%d) failed" % message.actor_)
return
# 设置玩家离线
actor.set_leave(True)
# 副本管理器中删除玩家ID和副本ID的映射关系
guild_types.PlayingManager.remove_actor(message.actor_)
proxy.Logging.debug("[guild] actor(%d) leave from playing" % message.actor_)
示例8: playing_plot_on_event_actor_killed
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_plot_on_event_actor_killed(message_type, channel, channel_type, serialize):
# 事件消息
message = ccevent.role.ttypes.EventRoleKilled()
# 消息反序列化
TSerialization.deserialize(message, serialize)
# 主角类型只能是玩家
if message.type_ != ccentity.entity.ttypes.EntityType.TYPE_ACTOR:
return None
# 根据玩家ID获取所在副本ID
playing_id = plot_types.PlayingManager.get_actor_playing(message.id_)
if playing_id == None or playing_id == 0:
proxy.Logging.error("plot_types.PlayingManager.get_actor_playing(%d) failed." % message.id_)
return None
# 获取副本对象
playing = plot_types.PlayingManager.get(playing_id)
if playing == None:
proxy.Logging.error("plot_types.PlayingManager.get(%d) failed." % playing_id)
return None
# 获取玩家对象
actor = playing.get_actor(message.id_)
if actor == None:
proxy.Logging.error("playing.get_actor(%d) failed." % message.id_)
return None
# 玩家死亡次数增加
actor.inc_dead_count(1)
log.log_debug("玩家(%d) 死亡次数(%d)" % (message.id_, actor.get_dead_count()))
示例9: playing_coliseum_on_event_playing_destroy
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_coliseum_on_event_playing_destroy(message_type, channel, channel_type, serialize):
# 事件消息
message = ccevent.playing.ttypes.EventPlayingDestory()
# 反序列化
TSerialization.deserialize(message, serialize)
# 移除定时器
proxy.Timer.remove(message.playing_, "playing_coliseum_on_timer_playing_start")
proxy.Timer.remove(message.playing_, "playing_coliseum_on_timer_summon_next_wave")
proxy.Timer.remove(message.playing_, "playing_coliseum_on_timer_remove_rune")
proxy.Timer.remove(message.playing_, "playing_coliseum_on_timer_expired")
# 取消关注玩家进入/退出副本
proxy.Communicator.unfollow(
ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_ENTER,
message.template_,
ccevent.ttypes.ChannelType.CHANNEL_PLAYING,
"playing_coliseum_on_event_playing_actor_enter",
)
proxy.Communicator.unfollow(
ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_LEAVE,
message.template_,
ccevent.ttypes.ChannelType.CHANNEL_PLAYING,
"playing_coliseum_on_event_playing_actor_leave",
)
# 从副本管理器中删除副本对象
coliseum_types.PlayingManager.remove(message.playing_)
proxy.Logging.debug("[coliseum] playing(%d,%d) destroy" % (message.playing_, message.template_))
示例10: playing_slaughter_house_on_event_actor_killed
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_slaughter_house_on_event_actor_killed(message_type, channel, channel_type, serialize):
message = ccevent.role.ttypes.EventRoleKilled()
TSerialization.deserialize(message, serialize)
if message.attacker_type_ != ccentity.entity.ttypes.EntityType.TYPE_ACTOR:
return None;
playing_id = slaughter_house_types.PlayingManager.get_actor_playing(message.id_)
if playing_id == None or playing_id == 0:
proxy.Logging.error("[slaughter_house] PlayingManager.get_actor_playing(%d) failed."\
% message.id_)
return None
playing = slaughter_house_types.PlayingManager.get(playing_id)
if playing == None:
proxy.Logging.error("[slaughter_house] PlayingManager.get(%d) failed." % playing_id)
return None
playing_config = slaughter_house_types.Config.get(playing.get_template())
if playing_config == None:
proxy.Logging.error("[slaughter_house] slaughter_house_types.Config.get(%d) failed."\
% playing.get_template())
return None
attacker_actor = playing.get_actor(message.attacker_id_)
if attacker_actor == None:
proxy.Logging.error("[slaughter_house] playing.get_actor(%d) failed."\
% message.attacker_id_)
return None
attacker_actor.score_ += playing_config.kill_actor_score_
playing.ranking_.add_score(message.attacker_id_, playing_config.kill_actor_score_)
proxy.Logging.debug("[slaughter_house] actor(%d) killed by actor(%d)"\
% (message.id_, message.attacker_id_))
示例11: playing_coliseum_on_event_playing_create
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_coliseum_on_event_playing_create(message_type, channel, channel_type, serialize):
# 事件消息
message = ccevent.playing.ttypes.EventPlayingCreate()
# 反序列化
TSerialization.deserialize(message, serialize)
# 关注玩家进入/退出副本事件
proxy.Communicator.follow(
ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_ENTER,
message.template_,
ccevent.ttypes.ChannelType.CHANNEL_PLAYING,
"playing_coliseum_on_event_playing_actor_enter",
)
proxy.Communicator.follow(
ccevent.ttypes.EventType.EVENT_PLAYING_ACTOR_LEAVE,
message.template_,
ccevent.ttypes.ChannelType.CHANNEL_PLAYING,
"playing_coliseum_on_event_playing_actor_leave",
)
# 创建副本对象并加入副本管理器
playing = coliseum_types.Playing(message.playing_, message.template_, message.scene_)
coliseum_types.PlayingManager.add(playing)
proxy.Logging.debug("[coliseum] playing(%d,%d,%d) create" % (message.playing_, message.template_, message.scene_))
示例12: message_handler
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def message_handler(self, msg): # CHECK: IS IT NECESSARY TO HAVE IT DECLARED IN THE SUPERCLASS IF YOU HAVE IT IN THE SUBCLASS?
logging.debug ("Entered function")
if len(msg) < 3:
logging.error("ERROR", "Received message is incomplete (topic, header or bodymsg may be missing)")
# ERROR
else:
topic = msg[0]
msg_header = TSerialization.deserialize(thrift.MsgHeader(), msg[1])
messagetype = ('CREATE', 'CONFIGURE', 'REQUEST', 'RELEASE', 'INFORM') ## DEBUGGING ONLY. ERASE AFTERWARDS!
logging.info("Got a message of type:%s", messagetype[msg_header.mtype])
function_mapper = ('CreateMsg', 'ConfigMsg', 'RequestMsg', 'ReleaseMsg')
# decoding_base = globals()["thrift."+function_mapper[msg_header.mtype]] ## REMOVE. This would produce a key error
decoding_base = getattr(thrift, function_mapper[msg_header.mtype])
bodymsg = TSerialization.deserialize(decoding_base(), msg[2])
coded_attachments = msg[3:len(msg)]
if topic != self.name and topic in self.topics: # Then it should be addressed to a group the node is member of
group = topic.split(".#")[0] # Since all topics end in ".#", it must be removed to get the group name.
else:
group = None
# TODO: Keep working on making it more generic later
if msg_header.mtype == thrift.MessageType.CREATE:
self.create (bodymsg.child_type, group, coded_attachments)
elif msg_header.mtype == thrift.MessageType.CONFIGURE:
self.configure(bodymsg)
elif msg_header.mtype == thrift.MessageType.REQUEST: #MOCKUP
body_base = thrift.RequestMsg()
elif msg_header.mtype == thrift.MessageType.RELEASE: #MOCKUP
body_base = thrift.ReleaseMsg()
else:
logging.error("ERROR", "Wrong MessageType: {0}".format(msg_header.mtype))
示例13: playing_slaughter_house_on_event_playing_actor_leave
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_slaughter_house_on_event_playing_actor_leave(message_type, channel, channel_type, serialize):
message = ccevent.playing.ttypes.EventPlayingActorLeave()
TSerialization.deserialize(message, serialize)
proxy.Communicator.unfollow(ccevent.ttypes.EventType.EVENT_ROLE_KILLED,\
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\
"playing_slaughter_house_on_event_actor_killed")
proxy.Communicator.unfollow(ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,\
message.actor_, ccevent.ttypes.ChannelType.CHANNEL_ACTOR,\
"playing_slaughter_house_on_event_actor_kill_npc")
playing = slaughter_house_types.PlayingManager.get(message.playing_)
if playing == None:
return None
actor = playing.get_actor(message.actor_)
if actor == None:
proxy.Logging.error("[slaughter_house] playing.get_actor(%d) failed." % message.actor_)
return None
actor.leaving_ = True;
slaughter_house_types.PlayingManager.remove_actor(message.actor_)
proxy.Logging.debug("[slaughter_house] actor(%d) leave from playing" % message.actor_)
示例14: playing_unreal_soul_on_event_role_leave_fighting_status
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_unreal_soul_on_event_role_leave_fighting_status(message_type, channel, channel_type, serialize):
message = ccevent.role.ttypes.EventRoleLeaveFightingStatus()
TSerialization.deserialize(message, serialize)
proxy.Logging.debug("[unreal_soul] EventRoleLeaveFightingStatus")
if message.type_ != ccentity.entity.ttypes.EntityType.TYPE_NPC:
return None
playing_id = unreal_soul_types.PlayingManager.get_monster_playing(message.id_)
if playing_id == 0:
proxy.Logging.error("[unreal_soul] PlayingManager.get_monster_playing(%d) failed." % message.id_)
return None
playing = unreal_soul_types.PlayingManager.get(playing_id)
if playing == None:
proxy.Logging.error("[unreal_soul] PlayingManager.get(%d) failed." % playing_id)
return None
monster = playing.get_monster(message.id_)
if monster == None:
proxy.Logging.error("[unreal_soul] Playing.get_monster(%d) failed." % message.id_)
return None
monster.fighting_status_ = False
proxy.Logging.debug("[unreal_soul] monster(%d) out of fighting status" % message.id_)
示例15: playing_unreal_soul_on_event_playing_actor_leave
# 需要导入模块: from thrift import TSerialization [as 别名]
# 或者: from thrift.TSerialization import deserialize [as 别名]
def playing_unreal_soul_on_event_playing_actor_leave(message_type, channel, channel_type, serialize):
message = ccevent.playing.ttypes.EventPlayingActorLeave()
TSerialization.deserialize(message, serialize)
proxy.Communicator.unfollow(
ccevent.ttypes.EventType.EVENT_ACTOR_KILL_NPC,
message.actor_,
ccevent.ttypes.ChannelType.CHANNEL_ACTOR,
"playing_unreal_soul_on_event_actor_kill_npc",
)
unreal_soul_types.PlayingManager.remove_actor(message.actor_)
playing = unreal_soul_types.PlayingManager.get(message.playing_)
if playing == None:
proxy.Logging.error("[unreal_soul] PlayingManager.get(%d) failed." % message.playing_)
return None
actor = playing.get_actor(message.actor_)
if actor == None:
proxy.Logging.error("[unreal_soul] Playing.get_actor(%d) failed." % message.actor_)
return None
actor.set_leave(True)
proxy.Logging.debug("[unreal_soul] actor(%d) leave from playing" % message.actor_)