gameServer/JoinsMonitor.hs
changeset 10005 800d1bd9021a
parent 9977 e2ecde00b2a7
child 10090 a471a7bbc339
equal deleted inserted replaced
10004:eb0b520564bb 10005:800d1bd9021a
    22     ioref <- newIORef Map.empty
    22     ioref <- newIORef Map.empty
    23     return (JoinsMonitor ioref)
    23     return (JoinsMonitor ioref)
    24 
    24 
    25 
    25 
    26 cleanup :: JoinsMonitor -> UTCTime -> IO ()
    26 cleanup :: JoinsMonitor -> UTCTime -> IO ()
    27 cleanup (JoinsMonitor ref) time = modifyIORef' ref f
    27 cleanup (JoinsMonitor ref) time = modifyIORef ref f
    28     where
    28     where
    29         f = Map.mapMaybe (\v -> let v' = takeWhile (\t -> diffUTCTime time t < 60*60) v in if null v' then Nothing else Just v')
    29         f = Map.mapMaybe (\v -> let v' = takeWhile (\t -> diffUTCTime time t < 60*60) v in if null v' then Nothing else Just v')
    30 
    30 
    31 
    31 
    32 joinsSentry :: JoinsMonitor -> B.ByteString -> UTCTime -> IO Bool
    32 joinsSentry :: JoinsMonitor -> B.ByteString -> UTCTime -> IO Bool