git » sdk » commit a58d3e7

Send session-terminate when connection fails

author Stephen Paul Weber
2025-06-24 18:35:13 UTC
committer Stephen Paul Weber
2025-06-24 18:35:13 UTC
parent 17875d01ff92dcb24601a4ade3f7759a3af11b0d

Send session-terminate when connection fails

snikket/jingle/Session.hx +6 -0

diff --git a/snikket/jingle/Session.hx b/snikket/jingle/Session.hx
index 7712441..8ead549 100644
--- a/snikket/jingle/Session.hx
+++ b/snikket/jingle/Session.hx
@@ -561,6 +561,12 @@ class InitiatedSession implements Session {
 			});
 			pc.addEventListener("connectionstatechange", (event) -> {
 				if (pc != null && (pc.connectionState == "closed" || pc.connectionState == "failed")) {
+					client.sendStanza(
+						new Stanza("iq", { to: counterpart.asString(), type: "set", id: ID.medium() })
+							.tag("jingle", { xmlns: "urn:xmpp:jingle:1", action: "session-terminate", sid: sid })
+							.tag("reason").tag("connectivity-error")
+							.up().up().up()
+					);
 					terminate();
 				}
 			});