Copyright | (c) Eric Mertens 2016 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
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
.
Synopsis
- data NetworkConnection
- data NetworkEvent
- createConnection :: Int -> ServerSettings -> IO NetworkConnection
- send :: NetworkConnection -> ByteString -> IO ()
- recv :: NetworkConnection -> STM [NetworkEvent]
- abortConnection :: TerminationReason -> NetworkConnection -> IO ()
- data TerminationReason
Documentation
data NetworkConnection Source #
Handle for a network connection
Instances
Show NetworkConnection Source # | |
Defined in Client.Network.Async showsPrec :: Int -> NetworkConnection -> ShowS # show :: NetworkConnection -> String # showList :: [NetworkConnection] -> ShowS # |
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 !ZonedTime [Text] | Event for successful connection to host (certificate lines) |
NetworkLine !ZonedTime !ByteString | Event for a new recieved line (newline removed) |
NetworkError !ZonedTime !SomeException | Report an error on network connection network connection failed |
NetworkClose !ZonedTime | Final message indicating the network connection finished |
:: Int | delay in seconds |
-> ServerSettings | |
-> 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.
recv :: NetworkConnection -> STM [NetworkEvent] Source #
Abort connections
abortConnection :: TerminationReason -> NetworkConnection -> IO () Source #
Force the given connection to terminate.
data TerminationReason Source #
Exceptions used to kill connections manually.
PingTimeout | sent when ping timer expires |
ForcedDisconnect | sent when client commands force disconnect |
StsUpgrade | sent when the client disconnects due to sts policy |
BadCertFingerprint ByteString (Maybe ByteString) | |
BadPubkeyFingerprint ByteString (Maybe ByteString) |
Instances
Show TerminationReason Source # | |
Defined in Client.Network.Async showsPrec :: Int -> TerminationReason -> ShowS # show :: TerminationReason -> String # showList :: [TerminationReason] -> ShowS # | |
Exception TerminationReason Source # | |
Defined in Client.Network.Async |