20 "UPDATE gameserver_stats SET players = ?, rooms = ?, last_update = UNIX_TIMESTAMP()" |
20 "UPDATE gameserver_stats SET players = ?, rooms = ?, last_update = UNIX_TIMESTAMP()" |
21 |
21 |
22 dbInteractionLoop dbConn = forever $ do |
22 dbInteractionLoop dbConn = forever $ do |
23 q <- (getLine >>= return . read) |
23 q <- (getLine >>= return . read) |
24 hPutStrLn stderr $ show q |
24 hPutStrLn stderr $ show q |
25 |
25 |
26 case q of |
26 case q of |
27 CheckAccount clUid clNick _ -> do |
27 CheckAccount clId clUid clNick _ -> do |
28 statement <- prepare dbConn dbQueryAccount |
28 statement <- prepare dbConn dbQueryAccount |
29 execute statement [SqlByteString $ clNick] |
29 execute statement [SqlByteString $ clNick] |
30 passAndRole <- fetchRow statement |
30 passAndRole <- fetchRow statement |
31 finish statement |
31 finish statement |
32 let response = |
32 let response = |
33 if isJust passAndRole then |
33 if isJust passAndRole then |
34 ( |
34 ( |
|
35 clId, |
35 clUid, |
36 clUid, |
36 HasAccount |
37 HasAccount |
37 (fromSql $ head $ fromJust $ passAndRole) |
38 (fromSql $ head $ fromJust $ passAndRole) |
38 ((fromSql $ last $ fromJust $ passAndRole) == (Just (3 :: Int))) |
39 ((fromSql $ last $ fromJust $ passAndRole) == (Just (3 :: Int))) |
39 ) |
40 ) |
40 else |
41 else |
41 (clUid, Guest) |
42 (clId, clUid, Guest) |
42 putStrLn (show response) |
43 putStrLn (show response) |
43 hFlush stdout |
44 hFlush stdout |
44 |
45 |
45 SendStats clients rooms -> |
46 SendStats clients rooms -> |
46 run dbConn dbQueryStats [SqlInt32 $ fromIntegral clients, SqlInt32 $ fromIntegral rooms] >> return () |
47 run dbConn dbQueryStats [SqlInt32 $ fromIntegral clients, SqlInt32 $ fromIntegral rooms] >> return () |