答:是的,你需要服務器端的功能。什麼服務器和你如何去做取決於你。 (例如,您可以使用Node.js和受的WebSockets) 下面的代碼使服務器應該能夠處理
var mess = JSON.parse(message.utf8Data);
switch(mess.type){
case "answer":
allClients.forEach(function (client){
//Locate the correct client and send the answer to it
});
break;
case "offer":
allClients.forEach(function (client){
//Locate the correct client and send the offer to it
});
break;
case "candidate":
allClients.forEach(function (client){
//Locate the correct candidate and send the candidate to it
});
break;
}
B.是功能性的例子。但我確定有防火牆設置可能會讓它很麻煩。無論如何,webRTC在很多這樣的情況下使用ICE來幫助。您會看到它會產生大量的「候選」消息,其中包含可幫助建立對等連接的信息。這實際上取決於您的服務器將這些候選消息轉發給對等方。
下好了,這牽涉到服務器...
想知道爲什麼一個DOWNVOTE ?? ... – AngelsandDemons