stun/turn fixes
This commit is contained in:
parent
28f5580936
commit
6c7146f8ab
@ -21,9 +21,25 @@ const CONFIG = {
|
||||
PEER_HEALTH_CHECK_INTERVAL: 10000,
|
||||
RTC_CONFIGURATION: {
|
||||
iceServers: [
|
||||
{ urls: 'stun:stun.l.google.com:19302' },
|
||||
{ urls: 'stun:stun1.l.google.com:19302' }
|
||||
{
|
||||
urls:
|
||||
[
|
||||
'stun:stun.l.google.com:19302',
|
||||
'stun:stun1.l.google.com:19302'
|
||||
]
|
||||
},
|
||||
// {
|
||||
// urls:
|
||||
// [
|
||||
// 'turn:openrelay.metered.ca:80',
|
||||
// 'turn:openrelay.metered.ca:80?transport=tcp',
|
||||
// 'turn:openrelay.metered.ca:443'
|
||||
// ],
|
||||
// username: 'openrelayproject',
|
||||
// credential: 'openrelayproject'
|
||||
// }
|
||||
]
|
||||
// iceTransportPolicy: 'relay',
|
||||
}
|
||||
},
|
||||
APP: {
|
||||
@ -873,22 +889,6 @@ class WebSocketManager {
|
||||
WebSocketManager.setupEventHandlers();
|
||||
}
|
||||
|
||||
static ping() {
|
||||
if (state.ws?.readyState !== WebSocket.OPEN) {
|
||||
return;
|
||||
}
|
||||
const buffer = new ArrayBuffer(7);
|
||||
const dataView = new DataView(buffer);
|
||||
dataView.setInt8(0, 0x89);
|
||||
dataView.setInt8(1, 0x00);
|
||||
dataView.setInt8(2, 0x48);
|
||||
dataView.setInt8(3, 0x65);
|
||||
dataView.setInt8(4, 0x6c);
|
||||
dataView.setInt8(5, 0x6c);
|
||||
dataView.setInt8(6, 0x6f);
|
||||
state.ws.send(buffer);
|
||||
}
|
||||
|
||||
static setupEventHandlers() {
|
||||
state.ws.onopen = () => {
|
||||
UIManager.updateConnectionStatus(true);
|
||||
@ -1139,6 +1139,10 @@ class PeerConnectionManager {
|
||||
};
|
||||
// Handle ICE candidates
|
||||
peerConnection.onicecandidate = (event) => {
|
||||
// if (event.candidate) {
|
||||
// console.log('🔗 ICE candidate type:', event.candidate.type);
|
||||
// console.log('🔗 ICE candidate:', event.candidate.candidate);
|
||||
// }
|
||||
if (event.candidate && state.ws && state.ws.readyState === WebSocket.OPEN) {
|
||||
console.log('🔗 Sending ICE candidate to:', remoteUserId);
|
||||
state.ws.send(JSON.stringify({
|
||||
@ -1148,6 +1152,11 @@ class PeerConnectionManager {
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
peerConnection.oniceconnectionstatechange = () => {
|
||||
console.log('🔗 Connection state change:', peerConnection.connectionState);
|
||||
}
|
||||
|
||||
// Handle connection state changes
|
||||
peerConnection.onconnectionstatechange = () => {
|
||||
console.log(`🔗 Connection state with ${remoteUserId}:`, peerConnection.connectionState);
|
||||
@ -2085,15 +2094,15 @@ class DebugUtils {
|
||||
}
|
||||
|
||||
// ==================== PERIODIC TASKS ====================
|
||||
setInterval(() => {
|
||||
if (state.isInVoiceChat) {
|
||||
console.log('🔄 Performing periodic voice chat maintenance tasks...');
|
||||
if (state.audioContext.state === 'suspended') {
|
||||
console.log('⚠️⚠️⚠️ Resuming suspended AudioContext');
|
||||
state.audioContext.resume();
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
// setInterval(() => {
|
||||
// if (state.isInVoiceChat) {
|
||||
// console.log('🔄 Performing periodic voice chat maintenance tasks...');
|
||||
// if (state.audioContext.state === 'suspended') {
|
||||
// console.log('⚠️⚠️⚠️ Resuming suspended AudioContext');
|
||||
// state.audioContext.resume();
|
||||
// }
|
||||
// }
|
||||
// }, 5000);
|
||||
|
||||
|
||||
$('.chat-messages').addEventListener('scroll', function() {
|
||||
@ -2155,4 +2164,4 @@ window.toggleEmojiPicker = UIManager.toggleEmojiPicker;
|
||||
// Debug functions
|
||||
window.debugVoiceSetup = DebugUtils.debugVoiceSetup;
|
||||
window.fixVoice = DebugUtils.fixVoice;
|
||||
window.scrollChatToBottom = UIManager.scrollChatToBottom;
|
||||
window.scrollChatToBottom = UIManager.scrollChatToBottom;
|
||||
|
Loading…
x
Reference in New Issue
Block a user