module ClientState where import Control.Concurrent.STM import Data.Text ( Text ) import Data.Int ( Int8 ) import Data.Bits ( (.&.) ) import UTmp ( ProcessID ) import XMPPServer ( Stanza ) data ClientState = ClientState { clientResource :: Text , clientUser :: Text , clientPid :: Maybe ProcessID , clientStatus :: TVar (Maybe Stanza) , clientFlags :: TVar Int8 } cf_available :: Int8 cf_available = 0x1 cf_interested :: Int8 cf_interested = 0x2 -- | True if the client has sent an initial presence clientIsAvailable c = do flgs <- readTVar (clientFlags c) return $ flgs .&. cf_available /= 0 -- | True if the client has requested a roster clientIsInterested c = do flgs <- readTVar (clientFlags c) return $ flgs .&. cf_interested /= 0