equal
deleted
inserted
replaced
17 dbQueryStats = |
17 dbQueryStats = |
18 "UPDATE gameserver_stats SET players = ?, rooms = ?, last_update = UNIX_TIMESTAMP()" |
18 "UPDATE gameserver_stats SET players = ?, rooms = ?, last_update = UNIX_TIMESTAMP()" |
19 |
19 |
20 dbInteractionLoop dbConn = forever $ do |
20 dbInteractionLoop dbConn = forever $ do |
21 q <- (getLine >>= return . read) |
21 q <- (getLine >>= return . read) |
|
22 hPutStrLn stderr $ show q |
22 |
23 |
23 case q of |
24 case q of |
24 CheckAccount clUid clNick _ -> do |
25 CheckAccount clUid clNick _ -> do |
25 statement <- prepare dbConn dbQueryAccount |
26 statement <- prepare dbConn dbQueryAccount |
26 execute statement [SqlString $ clNick] |
27 execute statement [SqlString $ clNick] |
35 ((fromSql $ last $ fromJust $ passAndRole) == (Just (3 :: Int))) |
36 ((fromSql $ last $ fromJust $ passAndRole) == (Just (3 :: Int))) |
36 ) |
37 ) |
37 else |
38 else |
38 (clUid, Guest) |
39 (clUid, Guest) |
39 putStrLn (show response) |
40 putStrLn (show response) |
|
41 hFlush stdout |
40 |
42 |
41 SendStats clients rooms -> do |
43 SendStats clients rooms -> |
42 statement <- prepare dbConn dbQueryStats |
44 run dbConn dbQueryStats [SqlInt32 $ fromIntegral clients, SqlInt32 $ fromIntegral rooms] >> return () |
43 execute statement [SqlInt32 $ fromIntegral clients, SqlInt32 $ fromIntegral rooms] |
|
44 finish statement |
|
45 |
45 |
46 hFlush stdout |
|
47 |
46 |
48 dbConnectionLoop mySQLConnectionInfo = |
47 dbConnectionLoop mySQLConnectionInfo = |
49 Control.Exception.handle (\e -> return ()) $ handleSqlError $ |
48 Control.Exception.handle (\e -> return ()) $ handleSqlError $ |
50 bracket |
49 bracket |
51 (connectMySQL mySQLConnectionInfo) |
50 (connectMySQL mySQLConnectionInfo) |