Pup-Events-Client-1.1.4: A networked event handling framework for hooking into other programs.

Safe HaskellSafe-Infered



The Clients module in the PupEvents framework is used by the main application code to send events to the server. Its main function, client returns a pair of PQueues that the application uses to send and receive events (written following the specification defined in the Events module).





:: Maybe [Char]

The address to connect to. If ommitted we connect to localhost

-> Int

The number of priorities in the PQueue

-> String

The port to start the client on.

-> (a -> Int)

A function to return the priority level of an event

-> (t -> t -> String)

A function to return the string representation of an event

-> [ParsecT [Char] () Identity a]

A list of parsers that return Event objects

-> IO (PQueue t, PQueue a, IO ())

We return a pair of PQueues to use in communicating events. The first is for all events going to the server, the second is for events coming from the server. We also return a function to manually close both the socket and handle we use to connect to the server.

The client function is the main entry point for the client code. It creates a socket, spawns two processes (sendEvents and recvEvents) to handle outgoing and incoming events, and returns the queues used to communicate with those processes.

sendEvents :: Handle -> PQueue t -> (t -> t -> String) -> IO ()Source

recvEvents :: Handle -> PQueue a -> (a -> Int) -> [ParsecT [Char] () Identity a] -> IO ()Source