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