Update environment configuration for production, refactor WebRTC components, and enhance chat functionality. Replace deprecated SessionUsersPanel with SessionPage, integrate chat history loading, and improve audio/video toggle handling. Remove unused SessionUsersPanel2 component and update related socket event handling in the server.

This commit is contained in:
2025-10-27 16:49:52 +05:00
parent 95f7b90d38
commit 2378ed1ff4
20 changed files with 936 additions and 304 deletions
+30 -6
View File
@@ -98,15 +98,33 @@ export const useWebRTC = (roomId?: string, autoJoin = false) => {
onParticipantLeft: (participantId) => {
setParticipants((prev) => prev.filter((p) => p.id !== participantId));
},
onParticipantAudioToggle: (participantId, isEnabled) => {
console.log(`[useWebRTC] Audio toggle for ${participantId}: ${isEnabled}`);
setParticipants((prev) =>
prev.map((p) =>
p.id === participantId ? { ...p, isMuted: !isEnabled } : p
)
);
},
onParticipantVideoToggle: (participantId, isEnabled) => {
console.log(`[useWebRTC] Video toggle for ${participantId}: ${isEnabled}`);
setParticipants((prev) =>
prev.map((p) =>
p.id === participantId ? { ...p, isVideoOff: !isEnabled } : p
)
);
},
onParticipantSpeakingChange: (participantId, isSpeaking) => {
setParticipants((prev) =>
prev.map((p) =>
p.id === participantId ? { ...p, isSpeaking } : p
)
);
},
onChatMessage: (message) => {
console.log("[useWebRTC] onChatMessage called:", message);
setChatMessages((prev) => [...prev, message]);
},
onDataChannelOpen: () => {
// DataChannel opened
},
onDataChannelClose: () => {
// DataChannel closed
},
onError: (error) => {
console.error("[useWebRTC] Error:", error);
},
@@ -202,6 +220,11 @@ export const useWebRTC = (roomId?: string, autoJoin = false) => {
setParticipants([]);
};
const updateSpeakingState = (isSpeaking: boolean) => {
if (!webrtcServiceInstance) return;
webrtcServiceInstance.updateSpeakingState(isSpeaking);
};
return {
localStream,
participants,
@@ -214,6 +237,7 @@ export const useWebRTC = (roomId?: string, autoJoin = false) => {
toggleAudio,
toggleVideo,
sendMessage,
updateSpeakingState,
joinRoom,
leaveRoom,
};