blob: 44d81b4f6fd16acabfbd94e70f1420e95bb8fc70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
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
|