gameServer/Actions.hs
changeset 4973 53411a26df7e
parent 4962 705c6186ad9d
child 4975 31da8979e5b1
equal deleted inserted replaced
4972:2f9c8a12edce 4973:53411a26df7e
    18 -----------------------------
    18 -----------------------------
    19 import CoreTypes
    19 import CoreTypes
    20 import Utils
    20 import Utils
    21 import ClientIO
    21 import ClientIO
    22 import ServerState
    22 import ServerState
       
    23 import Consts
    23 
    24 
    24 data Action =
    25 data Action =
    25     AnswerClients ![ClientChan] ![B.ByteString]
    26     AnswerClients ![ClientChan] ![B.ByteString]
    26     | SendServerMessage
    27     | SendServerMessage
    27     | SendServerVars
    28     | SendServerVars
   379         infoM "Clients" (show ci ++ ": New client. Time: " ++ show (connectTime cl))
   380         infoM "Clients" (show ci ++ ": New client. Time: " ++ show (connectTime cl))
   380 
   381 
   381         return ci
   382         return ci
   382 
   383 
   383     modify (\s -> s{clientIndex = Just newClId})
   384     modify (\s -> s{clientIndex = Just newClId})
   384     processAction $ AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/"]
   385     processAction $ AnswerClients [sendChan cl] ["CONNECTED", "Hedgewars server http://www.hedgewars.org/", serverVersion]
   385 
   386 
   386     let newLogins = takeWhile (\(_ , (time, _)) -> connectTime cl `diffUTCTime` time <= 0) $ lastLogins si
   387     let newLogins = takeWhile (\(_ , (time, _)) -> connectTime cl `diffUTCTime` time <= 0) $ lastLogins si
   387     let info = host cl `Prelude.lookup` newLogins
   388     let info = host cl `Prelude.lookup` newLogins
   388     if isJust info then
   389     if isJust info then
   389         mapM_ processAction [ModifyServerInfo (\s -> s{lastLogins = newLogins}), ByeClient (snd .  fromJust $ info)]
   390         mapM_ processAction [ModifyServerInfo (\s -> s{lastLogins = newLogins}), ByeClient (snd .  fromJust $ info)]