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
|
where
|
||||||
|
|
||||||
|
import BroadcastUserData (MonadBroadcast, broadcastUserData)
|
||||||
import ClassyPrelude
|
import ClassyPrelude
|
||||||
import Data.Aeson
|
import Data.Aeson
|
||||||
( FromJSON,
|
( FromJSON,
|
||||||
|
@ -16,6 +17,7 @@ import State.ConnectedClientsState
|
||||||
( MonadConnectedClientsModify,
|
( MonadConnectedClientsModify,
|
||||||
removeWSClient,
|
removeWSClient,
|
||||||
)
|
)
|
||||||
|
import State.RoomDataState (MonadRoomDataStateRead)
|
||||||
import Types.ConnectionState (Client (..))
|
import Types.ConnectionState (Client (..))
|
||||||
import Types.WebSocketMessages.WebSocketMessages (SetClientInfo (..))
|
import Types.WebSocketMessages.WebSocketMessages (SetClientInfo (..))
|
||||||
import WebSocket.Messages
|
import WebSocket.Messages
|
||||||
|
@ -56,9 +58,12 @@ newClientGeneric clientInfo = do
|
||||||
|
|
||||||
disconnectWsClient ::
|
disconnectWsClient ::
|
||||||
( MonadConnectedClientsModify m,
|
( MonadConnectedClientsModify m,
|
||||||
|
MonadRoomDataStateRead m,
|
||||||
|
MonadBroadcast m,
|
||||||
MonadWebSocketSession m
|
MonadWebSocketSession m
|
||||||
) =>
|
) =>
|
||||||
m ()
|
m ()
|
||||||
disconnectWsClient = do
|
disconnectWsClient = do
|
||||||
clientId <- getSesssionId
|
clientId <- getSesssionId
|
||||||
removeWSClient clientId
|
removeWSClient clientId
|
||||||
|
broadcastUserData
|
||||||
|
|
|
@ -18,9 +18,9 @@ runWebSocketServer ::
|
||||||
) =>
|
) =>
|
||||||
m ()
|
m ()
|
||||||
runWebSocketServer = do
|
runWebSocketServer = do
|
||||||
putStrLn "Websocket up at 127.0.0.1:9160"
|
putStrLn "Websocket up at 0.0.0.0:9160"
|
||||||
wsApp' <- runWSApp
|
wsApp' <- runWSApp
|
||||||
liftIO $ WS.runServer "127.0.0.1" 9160 wsApp'
|
liftIO $ WS.runServer "0.0.0.0" 9160 wsApp'
|
||||||
|
|
||||||
runWSApp ::
|
runWSApp ::
|
||||||
( MonadIO m,
|
( MonadIO m,
|
||||||
|
|
Loading…
Reference in a new issue