Close Connection on exception while connecting
This commit is contained in:
parent
c5a91968d6
commit
ab842462cf
1 changed files with 9 additions and 3 deletions
|
|
@ -51,7 +51,7 @@ type RecvQueue = TBQueue Recv
|
||||||
type EventQueue = TBQueue (Maybe Event) -- 'Nothing' ends the event stream
|
type EventQueue = TBQueue (Maybe Event) -- 'Nothing' ends the event stream
|
||||||
type LockedFlag = TVar Bool
|
type LockedFlag = TVar Bool
|
||||||
|
|
||||||
-- @ A connection to a room on euphoria.
|
-- | A connection to a room on euphoria.
|
||||||
--
|
--
|
||||||
-- __TODO__: Add more information on usage etc.
|
-- __TODO__: Add more information on usage etc.
|
||||||
data Connection = Connection LockedFlag SendQueue EventQueue
|
data Connection = Connection LockedFlag SendQueue EventQueue
|
||||||
|
|
@ -71,9 +71,15 @@ startEuphConnection host room = do
|
||||||
eventQueue <- atomically $ newTBQueue 10
|
eventQueue <- atomically $ newTBQueue 10
|
||||||
locked <- atomically $ newTVar False
|
locked <- atomically $ newTVar False
|
||||||
let euphCon = Connection locked sendQueue eventQueue
|
let euphCon = Connection locked sendQueue eventQueue
|
||||||
-- TODO: catch failed connection and send note to qEvent
|
void
|
||||||
void $ async $ WSS.runSecureClient host 443 ("/room/" ++ room ++ "/ws") (recvClient euphCon recvQueue)
|
$ forkIO
|
||||||
|
$ handle (handleException eventQueue)
|
||||||
|
$ WSS.runSecureClient host 443 ("/room/" ++ room ++ "/ws")
|
||||||
|
$ recvClient euphCon recvQueue
|
||||||
return euphCon
|
return euphCon
|
||||||
|
where
|
||||||
|
handleException :: EventQueue -> WS.HandshakeException -> IO ()
|
||||||
|
handleException qEvent _ = atomically $ writeTBQueue qEvent Nothing
|
||||||
|
|
||||||
{-
|
{-
|
||||||
- Fetch thread
|
- Fetch thread
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue