Use new LogIn server message, make sure the user is logged in after sending them the welcome message (so that they don't see themselves in the room) and broadcast the new LogIn message (to everyone including the newcomer)

This commit is contained in:
Tissevert 2019-12-08 23:00:29 +01:00
parent 9e228c7e94
commit 019909ba61

View file

@ -20,8 +20,9 @@ receive (Message.Hello {Message.name}) Nothing = do
sessionID <- asks App.sessionID
playerID <- App.exec (Server.register sessionID)
room <- App.get Server.room
App.update (Server.update sessionID $ Session.setPlayer playerID name)
Messaging.send $ Message.Welcome room playerID
App.update (Server.update sessionID $ Session.setPlayer playerID name)
Messaging.broadcast $ Message.LogIn playerID name
receive (Message.Hello {Message.name}) (Just player) = do
sessionID <- asks App.sessionID
@ -31,8 +32,9 @@ receive (Message.Hello {Message.name}) (Just player) = do
receive (Message.Tadaima {Message.myID, Message.name}) Nothing = do
sessionID <- asks App.sessionID
App.update $ Server.logIn name myID sessionID
Message.Okaeri <$> App.get Server.room >>= Messaging.send
App.update $ Server.logIn name myID sessionID
Messaging.broadcast $ Message.LogIn myID name
receive (Message.Tadaima {}) (Just _) = sendError "You're already logged in"