0
こんにちは私はWebRTC接続を確立するために、node.jsサーバーでwebsocketを使用しています。私は、接続を終了する場合でも、ノードサーバコンソールには、私に次のエラーを与える:WebSocket接続エラーを閉じる
conn.otherName = null;
^
TypeError: Cannot set property 'otherName' of undefined
その他の名称は、他のピアの名前であり、I'tsは、このような接続で、最大setted: ケース「のオファーを」: //例: UserAがUserBに電話をかけたいとします。 console.log( "送信先を:"、data.name);
//if UserB exists then send him offer details
var conn = users[data.name];
if(conn != null) {
//setting that UserA connected with UserB
connection.otherName = data.name;
sendTo(conn, {
type: "offer",
offer: data.offer,
name: connection.name
});
}
break;
case "answer":
console.log("Sending answer to: ", data.name);
//for ex. UserB answers UserA
var conn = users[data.name];
if(conn != null) {
connection.otherName = data.name;
sendTo(conn, {
type: "answer",
answer: data.answer
});
}
その後私はこのような接続を閉じています:
connection.on("close", function() {
if(connection.name) {
delete users[connection.name];
if(connection.otherName) {
console.log("Disconnecting from ", connection.otherName);
var conn = users[connection.otherName];
conn.otherName = null;
if(conn != null) {
sendTo(conn, {
type: "leave"
});
}
}
}
});
は、どのように私は私のノードサーバをクラッシュすることなく、接続を閉じることができるように変更できますか?破壊からそれを停止
まだそれでも動作しません:/ –
あなたは働いていないという意味ですか? – Mikkel
とにかくクラッシュします。問題は、「閉じる」メッセージを送信するボタンを2回クリックしたときです。既に閉じているので、undefinedを返して、同じエラーログを表示してクラッシュします。 –