equal
deleted
inserted
replaced
1 {-# LANGUAGE CPP #-} |
1 {-# LANGUAGE CPP, ScopedTypeVariables #-} |
2 module OfficialServer.DBInteraction |
2 module OfficialServer.DBInteraction |
3 ( |
3 ( |
4 startDBConnection |
4 startDBConnection |
5 ) where |
5 ) where |
6 |
6 |
50 (clId, accountInfo) <- hGetLine hOut >>= (maybeException . maybeRead) |
50 (clId, accountInfo) <- hGetLine hOut >>= (maybeException . maybeRead) |
51 |
51 |
52 writeChan coreChan $ ClientAccountInfo (clId, accountInfo) |
52 writeChan coreChan $ ClientAccountInfo (clId, accountInfo) |
53 |
53 |
54 return $ Map.insert clNick (currentTime, accountInfo) accountsCache |
54 return $ Map.insert clNick (currentTime, accountInfo) accountsCache |
55 `onException` |
55 `Exception.onException` |
56 (unGetChan queries q) |
56 (unGetChan queries q) |
57 else |
57 else |
58 do |
58 do |
59 writeChan coreChan $ ClientAccountInfo (clUid, snd $ fromJust cacheEntry) |
59 writeChan coreChan $ ClientAccountInfo (clUid, snd $ fromJust cacheEntry) |
60 return accountsCache |
60 return accountsCache |
61 |
61 |
62 ClearCache -> return Map.empty |
62 ClearCache -> return Map.empty |
63 SendStats {} -> onException ( |
63 SendStats {} -> ( |
64 (hPutStrLn hIn $ show q) >> |
64 (hPutStrLn hIn $ show q) >> |
65 hFlush hIn >> |
65 hFlush hIn >> |
66 return accountsCache) |
66 return accountsCache) |
|
67 `Exception.onException` |
67 (unGetChan queries q) |
68 (unGetChan queries q) |
68 |
69 |
69 pipeDbConnectionLoop queries coreChan hIn hOut updatedCache |
70 pipeDbConnectionLoop queries coreChan hIn hOut updatedCache |
70 where |
71 where |
71 maybeException (Just a) = return a |
72 maybeException (Just a) = return a |