glirc-2.15: Console IRC client

Copyright(c) Eric Mertens, 2016
Safe HaskellNone




This module creates network connections and thread to manage those connections. Events on these connections will be written to a given event queue, and outgoing messages are recieved on an incoming event queue.

These network connections are rate limited for outgoing messages per the rate limiting algorithm given in the IRC RFC.

Incoming network event messages are assumed to be framed by newlines.

When a network connection terminates normally its final messages will be NetworkClose. When it terminates abnormally its final message will be NetworkError.



type NetworkId = Int Source #

Identifier used to match connection events to connections.

data NetworkEvent Source #

The sum of incoming events from a network connection. All events are annotated with a network ID matching that given when the connection was created as well as the time at which the message was recieved.


NetworkOpen !NetworkId !ZonedTime

Event for successful connection to host

NetworkLine !NetworkId !ZonedTime !ByteString

Event for a new recieved line (newline removed)

NetworkError !NetworkId !ZonedTime !SomeException

Final message indicating the network connection failed

NetworkClose !NetworkId !ZonedTime

Final message indicating the network connection finished

createConnection Source #


:: Int

delay in seconds

-> NetworkId

Identifier to be used on incoming events

-> ConnectionContext 
-> ServerSettings 
-> TQueue NetworkEvent 
-> IO NetworkConnection 

Initiate a new network connection according to the given ServerSettings. All events on this connection will be added to the given queue. The resulting NetworkConnection value can be used for sending outgoing messages and for early termination of the connection.

send :: NetworkConnection -> ByteString -> IO () Source #

Schedule a message to be transmitted on the network connection. These messages are sent unmodified. The message should contain a newline terminator.

Abort connections

abortConnection :: TerminationReason -> NetworkConnection -> IO () Source #

Force the given connection to terminate.

data TerminationReason Source #

Exceptions used to kill connections manually.



sent when ping timer expires


sent when client commands force disconnect