gameServer/OfficialServer/DBInteraction.hs
changeset 1841 fba7210b438b
parent 1839 5dd4cb7fd7e5
child 1847 2178c0fc838c
equal deleted inserted replaced
1840:4747f0232b88 1841:fba7210b438b
    27 
    27 
    28 dbInteractionLoop queries coreChan dbConn = do
    28 dbInteractionLoop queries coreChan dbConn = do
    29 	q <- readChan queries
    29 	q <- readChan queries
    30 	case q of
    30 	case q of
    31 		CheckAccount clID name -> do
    31 		CheckAccount clID name -> do
    32 				statement <- prepare dbConn "SELECT uid FROM users WHERE name=?"
    32 				statement <- prepare dbConn "SELECT pass FROM users WHERE name=?"
    33 				execute statement [SqlString name]
    33 				execute statement [SqlString name]
    34 				uid <- fetchRow statement
    34 				pass <- fetchRow statement
    35 				finish statement
    35 				finish statement
    36 				if isJust uid then
    36 				if isJust pass then
    37 					writeChan coreChan $ ClientAccountInfo clID HasAccount
    37 					writeChan coreChan $ ClientAccountInfo clID (HasAccount $ fromSql $ head $ fromJust $ pass)
    38 					else
    38 					else
    39 					writeChan coreChan $ ClientAccountInfo clID Guest
    39 					writeChan coreChan $ ClientAccountInfo clID Guest
    40 			`onException`
    40 			`onException`
    41 				(unGetChan queries $ CheckAccount clID name)
    41 				(unGetChan queries $ CheckAccount clID name)
    42 		
    42