mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 12:14:12 +00:00 
			
		
		
		
	Rady to connect to other peers
This commit is contained in:
		@@ -232,6 +232,11 @@ class UserWebSocket {
 | 
			
		||||
			case "new_call_signal":
 | 
			
		||||
				SendEvent("newCallSignal", msg.data);
 | 
			
		||||
				break;
 | 
			
		||||
			
 | 
			
		||||
			case "call_peer_ready":
 | 
			
		||||
				SendEvent("callPeerReady", msg.data);
 | 
			
		||||
				break;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			default:
 | 
			
		||||
				console.error("WS Unspported kind of message!", msg);
 | 
			
		||||
 
 | 
			
		||||
@@ -97,6 +97,13 @@ document.addEventListener("newCallSignal", (e) => {
 | 
			
		||||
		OpenConversations.get(detail.callID).NewSignal(detail.peerID, detail.data)
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
document.addEventListener("callPeerReady", (e) => {
 | 
			
		||||
	const detail = e.detail;
 | 
			
		||||
 | 
			
		||||
	if(OpenConversations.has(detail.callID))
 | 
			
		||||
		OpenConversations.get(detail.callID).PeerReady(detail.peerID)
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
document.addEventListener("wsClosed", () => {
 | 
			
		||||
	// Close all the current conversations
 | 
			
		||||
 
 | 
			
		||||
@@ -96,6 +96,11 @@ class CallWindow extends CustomEvents {
 | 
			
		||||
				callID: this.conv.ID
 | 
			
		||||
			})
 | 
			
		||||
 | 
			
		||||
			// Start to connect to ready pears
 | 
			
		||||
			for(const user of currMembersList)
 | 
			
		||||
				if(user.userID != userID() && user.ready)
 | 
			
		||||
					await this.PeerReady(user.userID)
 | 
			
		||||
 | 
			
		||||
			// Start to stream audio & video
 | 
			
		||||
			await this.startStreaming();
 | 
			
		||||
 | 
			
		||||
@@ -195,6 +200,10 @@ class CallWindow extends CustomEvents {
 | 
			
		||||
				convID: this.conv.ID
 | 
			
		||||
			})
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
		if(this.mainPeer)
 | 
			
		||||
			this.mainPeer.destroy();
 | 
			
		||||
 | 
			
		||||
		if(propagate)
 | 
			
		||||
			this.emitEvent("close");
 | 
			
		||||
	}
 | 
			
		||||
@@ -325,6 +334,10 @@ class CallWindow extends CustomEvents {
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	async PeerReady(peerID) {
 | 
			
		||||
		alert("Start to receive " + peerID)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Handles new signals
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user