gameServer/ServerCore.hs
changeset 3673 45778b16b224
parent 3671 a94d1dc4a8d9
child 3741 73246d25dfe1
equal deleted inserted replaced
3671:a94d1dc4a8d9 3673:45778b16b224
    33 mainLoop :: StateT ServerState IO ()
    33 mainLoop :: StateT ServerState IO ()
    34 mainLoop = forever $ do
    34 mainLoop = forever $ do
    35     si <- gets serverInfo
    35     si <- gets serverInfo
    36     r <- liftIO $ readChan $ coreChan si
    36     r <- liftIO $ readChan $ coreChan si
    37 
    37 
       
    38     liftIO $ putStrLn $ "Core msg: " ++ show r
    38     case r of
    39     case r of
    39         Accept ci -> processAction (AddClient ci)
    40         Accept ci -> processAction (AddClient ci)
    40 
    41 
    41         ClientMessage (ci, cmd) -> do
    42         ClientMessage (ci, cmd) -> do
    42             liftIO $ debugM "Clients" $ (show ci) ++ ": " ++ (show cmd)
    43             liftIO $ debugM "Clients" $ (show ci) ++ ": " ++ (show cmd)
    44             removed <- gets removedClients
    45             removed <- gets removedClients
    45             when (not $ ci `Set.member` removed) $ do
    46             when (not $ ci `Set.member` removed) $ do
    46                 modify (\as -> as{clientIndex = Just ci})
    47                 modify (\as -> as{clientIndex = Just ci})
    47                 reactCmd cmd
    48                 reactCmd cmd
    48 
    49 
    49         Remove ci -> processAction (DeleteClient ci)
    50         Remove ci -> do
       
    51             liftIO $ debugM "Clients"  $ "DeleteClient: " ++ show ci
       
    52             processAction (DeleteClient ci)
    50 
    53 
    51                 --else
    54                 --else
    52                 --do
    55                 --do
    53                 --debugM "Clients" "Message from dead client"
    56                 --debugM "Clients" "Message from dead client"
    54                 --return (serverInfo, rnc)
    57                 --return (serverInfo, rnc)
    55 
    58 
    56         ClientAccountInfo (ci, info) -> do
    59         ClientAccountInfo (ci, info) -> do
    57             removed <- gets removedClients
    60             --should instead check ci exists and has same nick/hostname
    58             when (not $ ci `Set.member` removed) $
    61             --removed <- gets removedClients
    59                 processAction (ProcessAccountInfo info)
    62             --when (not $ ci `Set.member` removed) $ do
    60 
    63             --    modify (\as -> as{clientIndex = Just ci})
       
    64             --    processAction (ProcessAccountInfo info)
       
    65             return ()
       
    66             
    61         TimerAction tick ->
    67         TimerAction tick ->
    62                 mapM_ processAction $
    68                 mapM_ processAction $
    63                     PingAll : [StatsAction | even tick]
    69                     PingAll : [StatsAction | even tick]
    64 
    70 
    65 
    71