discord-haskell-1.14.0: Write bots for Discord in Haskell
Safe HaskellNone
LanguageHaskell2010

Discord.Internal.Gateway.EventLoop

Description

Provides logic code for interacting with the Discord websocket gateway. Realistically, this is probably lower level than most people will need

Synopsis

Documentation

data GatewayHandle Source #

Info the event processing loop needs to

Constructors

GatewayHandle 

Fields

data GatewayException Source #

Ways the gateway connection can fail with no possibility of recovery.

data LoopState Source #

State of the eventloop

Instances

Instances details
Show LoopState Source # 
Instance details

Defined in Discord.Internal.Gateway.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 Integer -> IO () Source #

Infinite loop to send heartbeats to the chan

sendableLoop :: Connection -> GatewayHandle -> SendablesData -> Chan Text -> IO () Source #

Infinite loop to send library/user events to discord with the actual websocket connection