Update app.py
Browse files
app.py
CHANGED
|
@@ -757,25 +757,13 @@ def handle_chat_peer_offer(data):
|
|
| 757 |
if room_id not in CHAT_ROOMS:
|
| 758 |
return
|
| 759 |
|
| 760 |
-
print(f"π€ Relaying offer: {from_session[:8]} β {to_session[:8]}")
|
| 761 |
-
|
| 762 |
-
# Find the recipient's socket ID
|
| 763 |
-
recipient_socket_id = None
|
| 764 |
-
for sid in CHAT_ROOMS[room_id]["active_sessions"]:
|
| 765 |
-
if sid == to_session:
|
| 766 |
-
# Get the actual Socket.IO socket ID for this session
|
| 767 |
-
# We need to find which socket belongs to this session
|
| 768 |
-
for socket_sid, session_data in request.namespace.rooms.items():
|
| 769 |
-
if room_id in session_data:
|
| 770 |
-
# This socket is in the room, check if it's the right session
|
| 771 |
-
# We'll emit to the room but exclude sender
|
| 772 |
-
break
|
| 773 |
|
| 774 |
-
# Emit
|
| 775 |
emit('chat_peer_offer', {
|
| 776 |
'from_session': from_session,
|
| 777 |
'offer': offer
|
| 778 |
-
},
|
| 779 |
|
| 780 |
@socketio.on('chat_peer_answer')
|
| 781 |
def handle_chat_peer_answer(data):
|
|
@@ -788,13 +776,13 @@ def handle_chat_peer_answer(data):
|
|
| 788 |
if room_id not in CHAT_ROOMS:
|
| 789 |
return
|
| 790 |
|
| 791 |
-
print(f"π€ Relaying answer: {from_session[:8]} β {to_session[:8]}")
|
| 792 |
|
| 793 |
-
# Emit
|
| 794 |
emit('chat_peer_answer', {
|
| 795 |
'from_session': from_session,
|
| 796 |
'answer': answer
|
| 797 |
-
},
|
| 798 |
|
| 799 |
@socketio.on('chat_ice_candidate')
|
| 800 |
def handle_chat_ice_candidate(data):
|
|
@@ -807,11 +795,11 @@ def handle_chat_ice_candidate(data):
|
|
| 807 |
if room_id not in CHAT_ROOMS:
|
| 808 |
return
|
| 809 |
|
| 810 |
-
# Emit
|
| 811 |
emit('chat_ice_candidate', {
|
| 812 |
'from_session': from_session,
|
| 813 |
'candidate': candidate
|
| 814 |
-
},
|
| 815 |
|
| 816 |
@socketio.on('leave_chat')
|
| 817 |
def handle_leave_chat(data):
|
|
|
|
| 757 |
if room_id not in CHAT_ROOMS:
|
| 758 |
return
|
| 759 |
|
| 760 |
+
print(f"π€ Relaying offer: {from_session[:8]}... β {to_session[:8]}...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 761 |
|
| 762 |
+
# Emit to the room, but skip the sender
|
| 763 |
emit('chat_peer_offer', {
|
| 764 |
'from_session': from_session,
|
| 765 |
'offer': offer
|
| 766 |
+
}, to=room_id, skip_sid=request.sid)
|
| 767 |
|
| 768 |
@socketio.on('chat_peer_answer')
|
| 769 |
def handle_chat_peer_answer(data):
|
|
|
|
| 776 |
if room_id not in CHAT_ROOMS:
|
| 777 |
return
|
| 778 |
|
| 779 |
+
print(f"π€ Relaying answer: {from_session[:8]}... β {to_session[:8]}...")
|
| 780 |
|
| 781 |
+
# Emit to the room, but skip the sender
|
| 782 |
emit('chat_peer_answer', {
|
| 783 |
'from_session': from_session,
|
| 784 |
'answer': answer
|
| 785 |
+
}, to=room_id, skip_sid=request.sid)
|
| 786 |
|
| 787 |
@socketio.on('chat_ice_candidate')
|
| 788 |
def handle_chat_ice_candidate(data):
|
|
|
|
| 795 |
if room_id not in CHAT_ROOMS:
|
| 796 |
return
|
| 797 |
|
| 798 |
+
# Emit to the room, but skip the sender
|
| 799 |
emit('chat_ice_candidate', {
|
| 800 |
'from_session': from_session,
|
| 801 |
'candidate': candidate
|
| 802 |
+
}, to=room_id, skip_sid=request.sid)
|
| 803 |
|
| 804 |
@socketio.on('leave_chat')
|
| 805 |
def handle_leave_chat(data):
|