Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Provides logic code for interacting with the Discord websocket gateway. Realistically, this is probably lower level than most people will need
Synopsis
- data GatewayHandle = GatewayHandle {
- gatewayHandleEvents :: Chan (Either GatewayException EventInternalParse)
- gatewayHandleUserSendables :: Chan GatewaySendable
- gatewayHandleLastStatus :: IORef (Maybe UpdateStatusOpts)
- gatewayHandleLastSequenceId :: IORef Integer
- gatewayHandleSessionId :: IORef Text
- gatewayHandleHostname :: IORef HostName
- gatewayHandleHeartbeatAckTimes :: IORef UTCTime
- gatewayHandleHeartbeatTimes :: IORef (UTCTime, UTCTime)
- newtype GatewayException = GatewayExceptionIntent Text
- data LoopState
- data SendablesData = SendablesData {}
- connectionLoop :: Auth -> GatewayIntent -> GatewayHandle -> Chan Text -> IO ()
- runEventLoop :: GatewayHandle -> SendablesData -> Chan Text -> IO LoopState
- getPayloadTimeout :: SendablesData -> Chan Text -> IO (Either ConnectionException GatewayReceivable)
- getPayload :: Connection -> Chan Text -> IO (Either ConnectionException GatewayReceivable)
- heartbeat :: SendablesData -> IORef (UTCTime, UTCTime) -> IORef Integer -> IO ()
- sendHeartbeat :: SendablesData -> IORef (UTCTime, UTCTime) -> Integer -> IO ()
- sendableLoop :: Connection -> GatewayHandle -> SendablesData -> Chan Text -> IO ()
- dupe :: a -> (a, a)
Documentation
data GatewayHandle Source #
Info the event processing loop needs to
GatewayHandle | |
|
newtype GatewayException Source #
Ways the gateway connection can fail with no possibility of recovery.
Instances
Show GatewayException Source # | |
Defined in Discord.Internal.Gateway.EventLoop showsPrec :: Int -> GatewayException -> ShowS # show :: GatewayException -> String # showList :: [GatewayException] -> ShowS # |
State of the eventloop
data SendablesData Source #
Info the sendableLoop reads when it writes to the websocket
connectionLoop :: Auth -> GatewayIntent -> GatewayHandle -> Chan Text -> IO () Source #
Gateway connection infinite loop. Get events from websocket and send them to the library user
Auth needed to connect GatewayIntent needed to connect GatewayHandle (eventsGives,status,usersends,seq,sesh) needed all over log :: Chan (T.Text) needed all over sendableConnection set by setup, need sendableLoop librarySendables :: Chan (GatewaySendableInternal) set by setup, need heartbeat heartbeatInterval :: Int set by Hello, need heartbeat sequenceId :: Int id of last event received set by Resume, need heartbeat and reconnect sessionId :: Text set by Ready, need reconnect
runEventLoop :: GatewayHandle -> SendablesData -> Chan Text -> IO LoopState Source #
Process events from discord and write them to the onDiscordEvent Channel
getPayloadTimeout :: SendablesData -> Chan Text -> IO (Either ConnectionException GatewayReceivable) Source #
Blocking wait for next payload from the websocket (returns Reconnect after 1.5*heartbeatInterval seconds)
getPayload :: Connection -> Chan Text -> IO (Either ConnectionException GatewayReceivable) Source #
Blocking wait for next payload from the websocket
heartbeat :: SendablesData -> IORef (UTCTime, UTCTime) -> IORef Integer -> IO () Source #
Infinite loop to send heartbeats to the chan
sendHeartbeat :: SendablesData -> IORef (UTCTime, UTCTime) -> Integer -> IO () Source #
sendableLoop :: Connection -> GatewayHandle -> SendablesData -> Chan Text -> IO () Source #
Infinite loop to send library/user events to discord with the actual websocket connection