Stop broadcasting to clients not yet logged in

This commit is contained in:
Tissevert 2019-12-23 09:23:32 +01:00
parent d17edb201d
commit c329ed556c

View file

@ -27,7 +27,7 @@ import Hanafuda.Message (FromClient(..), T(..))
import qualified Hanafuda.Message as Message (T) import qualified Hanafuda.Message as Message (T)
import Network.WebSockets (receiveData, sendTextData) import Network.WebSockets (receiveData, sendTextData)
import Player (playerID, showDebug) import Player (playerID, showDebug)
import qualified Server (T(..), sessionsWhere) import qualified Server (sessionsWhere)
import qualified Session (T(..)) import qualified Session (T(..))
sendToSessions :: [Session.T] -> Message.T -> App.T () sendToSessions :: [Session.T] -> Message.T -> App.T ()
@ -52,7 +52,9 @@ send obj = do
broadcast :: Message.T -> App.T () broadcast :: Message.T -> App.T ()
broadcast obj = do broadcast obj = do
App.get (elems . Server.sessions) >>= flip sendToSessions obj App.get (concat . elems . allSessions) >>= flip sendToSessions obj
where
allSessions = Server.sessionsWhere (\_ _ -> True)
relay :: FromClient -> (Message.T -> App.T ()) -> App.T () relay :: FromClient -> (Message.T -> App.T ()) -> App.T ()
relay message f = do relay message f = do