ciyidogan commited on
Commit
c7d88b3
·
verified ·
1 Parent(s): 285eb62

Update websocket_manager.py

Browse files
Files changed (1) hide show
  1. websocket_manager.py +41 -3
websocket_manager.py CHANGED
@@ -281,12 +281,43 @@ class WebSocketManager:
281
  elif message_type == "control":
282
  # Control messages
283
  action = message.get("action")
 
284
 
285
- if action == "start_session":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  await self.event_bus.publish(Event(
287
- type=EventType.SESSION_STARTED,
288
  session_id=session_id,
289
- data=message.get("config", {})
 
 
 
 
 
 
 
290
  ))
291
 
292
  elif action == "end_session":
@@ -303,6 +334,13 @@ class WebSocketManager:
303
  data={}
304
  ))
305
 
 
 
 
 
 
 
 
306
  elif message_type == "ping":
307
  # Respond to ping
308
  await self.send_message(session_id, {"type": "pong"})
 
281
  elif message_type == "control":
282
  # Control messages
283
  action = message.get("action")
284
+ config = message.get("config", {})
285
 
286
+ if action == "start_conversation":
287
+ # Yeni action: Mevcut session için conversation başlat
288
+ log_info(f"🎤 Starting conversation for session | session_id={session_id}")
289
+
290
+ await self.event_bus.publish(Event(
291
+ type=EventType.CONVERSATION_STARTED,
292
+ session_id=session_id,
293
+ data={
294
+ "config": config,
295
+ "continuous_listening": config.get("continuous_listening", True)
296
+ }
297
+ ))
298
+
299
+ # Send confirmation to client
300
+ await self.send_message(session_id, {
301
+ "type": "conversation_started",
302
+ "message": "Conversation started successfully"
303
+ })
304
+
305
+ elif action == "start_session":
306
+ # Bu artık kullanılmamalı
307
+ log_warning(f"⚠️ Deprecated start_session action received | session_id={session_id}")
308
+
309
+ # Yine de işle ama conversation_started olarak
310
  await self.event_bus.publish(Event(
311
+ type=EventType.CONVERSATION_STARTED,
312
  session_id=session_id,
313
+ data=config
314
+ ))
315
+
316
+ elif action == "stop_session":
317
+ await self.event_bus.publish(Event(
318
+ type=EventType.CONVERSATION_ENDED,
319
+ session_id=session_id,
320
+ data={"reason": "user_request"}
321
  ))
322
 
323
  elif action == "end_session":
 
334
  data={}
335
  ))
336
 
337
+ else:
338
+ log_warning(
339
+ f"⚠️ Unknown control action",
340
+ session_id=session_id,
341
+ action=action
342
+ )
343
+
344
  elif message_type == "ping":
345
  # Respond to ping
346
  await self.send_message(session_id, {"type": "pong"})