Skip to content

Commit 8992a00

Browse files
committed
try catch write to data channel
1 parent 434acf0 commit 8992a00

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/backend/swarm.cjs

+15-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ async function send_voice_channel_sdp(data) {
3434
if (!con) return
3535
//We switch data address because in this case, it is from, we can change this
3636
data.address = Hugin.address
37-
con.connection.write(JSON.stringify(data))
37+
try {
38+
con.connection.write(JSON.stringify(data))
39+
} catch(e) {}
3840
}
3941

4042
const send_voice_channel_status = async (joined, status, update = false) => {
@@ -131,7 +133,9 @@ const end_swarm = async (key) => {
131133
}
132134

133135
active.connections.forEach(chat => {
136+
try {
134137
chat.connection.write(JSON.stringify({type: "disconnected"}))
138+
} catch(e) {}
135139
connection_closed(chat.connection, topic)
136140
})
137141

@@ -696,8 +700,9 @@ const send_joined_message = async (topic, dht_keys, connection) => {
696700
videoMute,
697701
screenshare
698702
})
699-
700-
connection.write(data)
703+
try {
704+
connection.write(data)
705+
} catch(e) {}
701706
}
702707

703708
const incoming_message = async (data, topic, connection, peer) => {
@@ -776,7 +781,9 @@ const check_online_state = async (topic) => {
776781
if (i > 4) {
777782
if (i % 2 === 0) data.hashes = []
778783
}
784+
try {
779785
conn.connection.write(JSON.stringify(data))
786+
} catch(e) {}
780787
i++
781788
}
782789
}
@@ -867,7 +874,11 @@ const send_peer_message = (address, topic, message) => {
867874
return
868875
}
869876
console.log("Sending peer message")
870-
con.connection.write(JSON.stringify(message))
877+
try {
878+
con.connection.write(JSON.stringify(message))
879+
} catch(e) {
880+
return
881+
}
871882
}
872883

873884

0 commit comments

Comments
 (0)