心跳包回复的数据前四位是人气值
Closed this issue · 3 comments
wosiwq commented
yulinfeng000 commented
好的,多谢
wosiwq commented
DEFAULT_POPULARITY = 1
popularity = struct.unpack("!I", data[:4])[0]
if popularity != DEFAULT_POPULARITY:
packages.append(
(header, f'{{"cmd": "HEARTBEAT", "popularity": {popularity}}}'))
我现在用这种方式把它模拟成一个cmd来把人气拿出来,有其他更优雅的实现方式吗?
yulinfeng000 commented
已经改成通过cmd进行处理
@app.on(Events.HEARTBEAT_REPLY)
async def liver_popularity(ctx):
print(ctx.body['popularity'])