This commit is contained in:
xyj 2024-01-28 14:32:42 +08:00
parent deb5bba325
commit 5260cadf6c
1 changed files with 3 additions and 2 deletions

View File

@ -259,14 +259,14 @@ async def process_data(request: Request):
data = json.loads(data)
event = data["event"]
clientid = data["clientid"]
print(clientid)
print(clientid + "======" + event)
pattern = r'^farm_[a-zA-Z0-9]{12}$'
amatch1 = re.match(pattern, clientid)
pattern = r'^test'
amatch2 = re.match(pattern, clientid)
# 如果两个都不满足,那就错误
if not amatch1 and not amatch2:
return BaseResponse(code=500, msg="不符合畜牧clientId")
return BaseResponse(code=200, msg="error")
# 连接成功处理
if event == "client.connected":
return await client_change_status(clientid, True)
@ -276,6 +276,7 @@ async def process_data(request: Request):
# 消息体处理
elif event == "message.publish":
return await message_publish(data)
return BaseResponse()
except Exception as e:
return BaseResponse(code=500, msg=str(e))