Copyright | (c) Eric Mertens 2016 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Client.Network.Async
Contents
Description
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]
- upgrade :: NetworkConnection -> IO ()
- abortConnection :: TerminationReason -> NetworkConnection -> IO ()
- data TerminationReason
Documentation
data NetworkConnection Source #
Handle for a network connection
Instances
Show NetworkConnection Source # | |
Defined in Client.Network.Async Methods 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.
Constructors
NetworkOpen !ZonedTime | Event for successful connection to host (certificate lines) |
NetworkTLS [Text] | Event indicating TLS is in effect |
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 |
Arguments
:: 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 #
upgrade :: NetworkConnection -> IO () Source #
Signals that the server is ready to initiate the TLS handshake. This is a no-op when not in a starttls state.
Abort connections
abortConnection :: TerminationReason -> NetworkConnection -> IO () Source #
Force the given connection to terminate.
data TerminationReason Source #
Exceptions used to kill connections manually.
Constructors
PingTimeout | sent when ping timer expires |
ForcedDisconnect | sent when client commands force disconnect |
StsUpgrade | sent when the client disconnects due to sts policy |
StartTLSFailed | STARTTLS was expected by server had an error |
BadCertFingerprint ByteString (Maybe ByteString) | |
BadPubkeyFingerprint ByteString (Maybe ByteString) |
Instances
Exception TerminationReason Source # | |
Defined in Client.Network.Async Methods toException :: TerminationReason -> SomeException # | |
Show TerminationReason Source # | |
Defined in Client.Network.Async Methods showsPrec :: Int -> TerminationReason -> ShowS # show :: TerminationReason -> String # showList :: [TerminationReason] -> ShowS # |