feat: update RTC bot migration and device interaction consumers
All checks were successful
Build and Deploy LTY / build-and-deploy (push) Successful in 9m19s
All checks were successful
Build and Deploy LTY / build-and-deploy (push) Successful in 9m19s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8dcef0cff2
commit
29b4913723
@ -201,7 +201,11 @@
|
||||
"Bash(cmd //c \"netstat -ano | findstr LISTENING | findstr /R \\\\\"8000 3000\\\\\"\")",
|
||||
"Bash(cmd //c \"netstat -ano\")",
|
||||
"Bash(/c/python/python.exe -m daphne -b 0.0.0.0 -p 8000 qy_lty.asgi:application)",
|
||||
"Bash(kill %1)"
|
||||
"Bash(kill %1)",
|
||||
"Bash(python -c ':*)",
|
||||
"Bash(xargs ls:*)",
|
||||
"Bash(find /c/Users/admin/Desktop/Lila-Server -name \"*.py\" -exec grep -l \"connect\\\\|disconnect\\\\|presence\\\\|heartbeat\" {} \\\\;)",
|
||||
"Bash(grep -E \"\\\\.py$|app$\")"
|
||||
],
|
||||
"additionalDirectories": [
|
||||
"C:\\Users\\admin\\.claude"
|
||||
|
||||
@ -3,9 +3,16 @@ from django.db import migrations
|
||||
|
||||
def create_rtc_bot(apps, schema_editor):
|
||||
Bot = apps.get_model('aiapp', 'Bot')
|
||||
Bot.objects.get_or_create(
|
||||
if not Bot.objects.filter(name='RTC_Voice_Agent').exists():
|
||||
# 手动指定一个不会冲突的 id
|
||||
from django.db import connection
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute("SELECT COALESCE(MAX(id), 0) + 1 FROM aiapp_bot")
|
||||
next_id = cursor.fetchone()[0]
|
||||
Bot.objects.create(
|
||||
id=next_id,
|
||||
name='RTC_Voice_Agent',
|
||||
defaults={'description': 'RTC实时语音智能体'}
|
||||
description='RTC实时语音智能体'
|
||||
)
|
||||
|
||||
|
||||
|
||||
@ -359,6 +359,21 @@ class DeviceConsumer(AsyncWebsocketConsumer):
|
||||
'status': 'success',
|
||||
'message': '恢复出厂设置指令已发送'
|
||||
}))
|
||||
elif message_type == 'device_state':
|
||||
# 处理手机设备状态消息
|
||||
await self.channel_layer.group_send(
|
||||
self.group_name,
|
||||
{
|
||||
'type': 'device_state',
|
||||
'message': message,
|
||||
'user_id': self.user_id
|
||||
}
|
||||
)
|
||||
|
||||
await self.send(text_data=json.dumps({
|
||||
'status': 'success',
|
||||
'message': '设备状态消息已发送'
|
||||
}))
|
||||
else:
|
||||
# 处理普通文本消息
|
||||
await self.channel_layer.group_send(
|
||||
@ -548,6 +563,23 @@ class DeviceConsumer(AsyncWebsocketConsumer):
|
||||
except Exception as e:
|
||||
logger.error(f"Error in factory_reset: {str(e)}")
|
||||
|
||||
async def device_state(self, event):
|
||||
"""
|
||||
处理手机设备状态消息
|
||||
将设备状态信息转发给 WebSocket
|
||||
"""
|
||||
try:
|
||||
message = event['message']
|
||||
user_id = event['user_id']
|
||||
|
||||
await self.send(text_data=json.dumps({
|
||||
'type': 'device_state',
|
||||
'message': message,
|
||||
'user_id': user_id
|
||||
}))
|
||||
except Exception as e:
|
||||
logger.error(f"Error in device_state: {str(e)}")
|
||||
|
||||
async def device_info(self, event):
|
||||
"""
|
||||
处理设备信息上报消息
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user