summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-07-17 21:39:22 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2025-07-17 21:39:22 +0200
commitd438e42a8047c3ea37ec2f0eaa8010fb22fc21d6 (patch)
tree7b400e787139d12fd4f70250825278536b84aa9a
parentf87fdcc65008fb40e8f0f37f33f6bbae1afa162a (diff)
Destroy ICE and close WS sessions on connection termination
-rw-r--r--main/WebSocket.hs6
-rw-r--r--src/Erebos/ICE.chs1
-rw-r--r--src/Erebos/Network.hs1
3 files changed, 5 insertions, 3 deletions
diff --git a/main/WebSocket.hs b/main/WebSocket.hs
index 5c49aa1..7a957e2 100644
--- a/main/WebSocket.hs
+++ b/main/WebSocket.hs
@@ -27,8 +27,10 @@ instance Show WebSocketAddress where
show (WebSocketAddress _ _) = "websocket"
instance PeerAddressType WebSocketAddress where
- sendBytesToAddress (WebSocketAddress _ conn) msg = do
- WS.sendDataMessage conn $ WS.Binary $ BL.fromStrict msg
+ sendBytesToAddress (WebSocketAddress _ conn) msg = do
+ WS.sendDataMessage conn $ WS.Binary $ BL.fromStrict msg
+ connectionToAddressClosed (WebSocketAddress _ conn) = do
+ WS.sendClose conn BL.empty
startWebsocketServer :: Server -> String -> Int -> (String -> IO ()) -> IO ()
startWebsocketServer server addr port logd = do
diff --git a/src/Erebos/ICE.chs b/src/Erebos/ICE.chs
index bed186b..a3dd9bc 100644
--- a/src/Erebos/ICE.chs
+++ b/src/Erebos/ICE.chs
@@ -66,6 +66,7 @@ instance Show IceSession where
instance PeerAddressType IceSession where
sendBytesToAddress = iceSend
+ connectionToAddressClosed = iceDestroy
data IceRemoteInfo = IceRemoteInfo
diff --git a/src/Erebos/Network.hs b/src/Erebos/Network.hs
index 6126e60..e990fae 100644
--- a/src/Erebos/Network.hs
+++ b/src/Erebos/Network.hs
@@ -164,7 +164,6 @@ instance Eq Peer where
class (Eq addr, Ord addr, Show addr, Typeable addr) => PeerAddressType addr where
sendBytesToAddress :: addr -> ByteString -> IO ()
connectionToAddressClosed :: addr -> IO ()
- connectionToAddressClosed _ = return ()
data PeerAddress
= forall addr. PeerAddressType addr => CustomPeerAddress addr