Broadcast on disconnect and websocket server fix for docker
This commit is contained in:
parent
30bfc6e763
commit
b01b637a22
|
@ -6,6 +6,7 @@ module WebSocket.MonadWebSocketSession
|
|||
)
|
||||
where
|
||||
|
||||
import BroadcastUserData (MonadBroadcast, broadcastUserData)
|
||||
import ClassyPrelude
|
||||
import Data.Aeson
|
||||
( FromJSON,
|
||||
|
@ -16,6 +17,7 @@ import State.ConnectedClientsState
|
|||
( MonadConnectedClientsModify,
|
||||
removeWSClient,
|
||||
)
|
||||
import State.RoomDataState (MonadRoomDataStateRead)
|
||||
import Types.ConnectionState (Client (..))
|
||||
import Types.WebSocketMessages.WebSocketMessages (SetClientInfo (..))
|
||||
import WebSocket.Messages
|
||||
|
@ -56,9 +58,12 @@ newClientGeneric clientInfo = do
|
|||
|
||||
disconnectWsClient ::
|
||||
( MonadConnectedClientsModify m,
|
||||
MonadRoomDataStateRead m,
|
||||
MonadBroadcast m,
|
||||
MonadWebSocketSession m
|
||||
) =>
|
||||
m ()
|
||||
disconnectWsClient = do
|
||||
clientId <- getSesssionId
|
||||
removeWSClient clientId
|
||||
broadcastUserData
|
||||
|
|
|
@ -18,9 +18,9 @@ runWebSocketServer ::
|
|||
) =>
|
||||
m ()
|
||||
runWebSocketServer = do
|
||||
putStrLn "Websocket up at 127.0.0.1:9160"
|
||||
putStrLn "Websocket up at 0.0.0.0:9160"
|
||||
wsApp' <- runWSApp
|
||||
liftIO $ WS.runServer "127.0.0.1" 9160 wsApp'
|
||||
liftIO $ WS.runServer "0.0.0.0" 9160 wsApp'
|
||||
|
||||
runWSApp ::
|
||||
( MonadIO m,
|
||||
|
|
Loading…
Reference in a new issue