- type Connection = ForeignPtr ConnectionTag
- data BusType
- busGet :: BusType -> IO Connection
- busConnectionUnref :: Connection -> IO ()
- send :: Connection -> Message -> Word32 -> IO Word32
- sendWithReplyAndBlock :: Connection -> Message -> Int -> IO Message
- flush :: Connection -> IO ()
- close :: Connection -> IO ()
- withConnection :: BusType -> (Connection -> IO a) -> IO a
- readWriteDispatch :: Connection -> Int -> IO Bool
- addFilter :: Connection -> (Message -> IO Bool) -> IO ()
- addMatch :: Connection -> Bool -> String -> IO ()
- data RequestNameReply
- = PrimaryOwner
- | InQueue
- | Exists
- | AlreadyOwner
- busRequestName :: Connection -> String -> [Int] -> IO RequestNameReply
Connection Basics
type Connection = ForeignPtr ConnectionTagSource
Multiple buses may be active simultaneously on a single system. The BusType indicates which one to use.
busGet :: BusType -> IO ConnectionSource
Connect to a standard bus.
busConnectionUnref :: Connection -> IO ()Source
Force the dereference of a connection. Note that this is usually not necessary since the connections are garbage collected automatically.
:: Connection | |
-> Message | |
-> Word32 | Serial. |
-> IO Word32 | Returned serial. |
Adds a Message
to the outgoing message queue.
:: Connection | |
-> Message | |
-> Int | Timeout in milliseconds. |
-> IO Message |
flush :: Connection -> IO ()Source
Block until all pending messages have been sent.
close :: Connection -> IO ()Source
withConnection :: BusType -> (Connection -> IO a) -> IO aSource
Open a connection and run an IO action, ensuring it is properly closed when you're done.
Main Loop Management
:: Connection | |
-> Int | Timeout, in milliseconds. |
-> IO Bool |
Block until a message is read or written, then return True unless a disconnect message is received.
:: Connection | |
-> Bool | Whether to block waiting for a response, allowing us to raise an exception if a response never comes. |
-> String | |
-> IO () |
busRequestName :: Connection -> String -> [Int] -> IO RequestNameReplySource