discord-haskell-voice-2.2.1: Voice support for discord-haskell.
Copyright(c) Yuto Takano (2021)
LicenseMIT
Maintainermoa17stock@gmail.com
Safe HaskellNone
LanguageHaskell2010

Discord.Internal.Types.VoiceCommon

Description

WARNING

This module is considered internal.

The Package Versioning Policy does not apply.

The contents of this module may change in any way whatsoever and without any warning between minor versions of this package.

Description

This module defines the types for handles, errors, base monads, and other types applicable to both the UPD and Websocket components of the Voice API. Many of the structures defined in this module have Lenses derived for them using Template Haskell.

Synopsis

Documentation

newtype Voice a Source #

Voice is a newtype Monad containing a composition of ReaderT and ExceptT transformers over the DiscordHandler monad. It holds references to voice connections/threads. The content of the reader handle is strictly internal and is hidden deliberately behind the newtype wrapper.

Developer Note: ExceptT is on the base rather than ReaderT, so that when a critical exception/error occurs in Voice, it can propagate down the transformer stack, kill the threads referenced in the Reader state as necessary, and halt the entire computation and return to DiscordHandler. If ExceptT were on top of ReaderT, then errors would be swallowed before it propagates below ReaderT, and the monad would not halt there, continuing computation with an unstable state.

Instances

Instances details
Monad Voice Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

(>>=) :: Voice a -> (a -> Voice b) -> Voice b #

(>>) :: Voice a -> Voice b -> Voice b #

return :: a -> Voice a #

Functor Voice Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

fmap :: (a -> b) -> Voice a -> Voice b #

(<$) :: a -> Voice b -> Voice a #

MonadFail Voice Source #

MonadFail is for internal use, identical in function to the MonadFail instance of ReaderT.

Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

fail :: String -> Voice a #

Applicative Voice Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

pure :: a -> Voice a #

(<*>) :: Voice (a -> b) -> Voice a -> Voice b #

liftA2 :: (a -> b -> c) -> Voice a -> Voice b -> Voice c #

(*>) :: Voice a -> Voice b -> Voice b #

(<*) :: Voice a -> Voice b -> Voice a #

MonadIO Voice Source #

MonadIO gives the ability to perform liftIO.

Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

liftIO :: IO a -> Voice a #

MonadThrow Voice Source #

MonadThrow, MonadCatch, and MonadMask are for internal use, to utilise exception handling functions like bracket.

Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

throwM :: Exception e => e -> Voice a #

MonadCatch Voice Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

catch :: Exception e => Voice a -> (e -> Voice a) -> Voice a #

MonadMask Voice Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

mask :: ((forall a. Voice a -> Voice a) -> Voice b) -> Voice b #

uninterruptibleMask :: ((forall a. Voice a -> Voice a) -> Voice b) -> Voice b #

generalBracket :: Voice a -> (a -> ExitCase b -> Voice c) -> (a -> Voice b) -> Voice (b, c) #

MonadReader DiscordBroadcastHandle Voice Source #

MonadReader is for internal use, to read the held broadcast handle.

Instance details

Defined in Discord.Internal.Types.VoiceCommon

MonadError VoiceError Voice Source #

MonadError is for internal use, to propagate errors.

Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

throwError :: VoiceError -> Voice a #

catchError :: Voice a -> (VoiceError -> Voice a) -> Voice a #

data VoiceError Source #

VoiceError represents the potential errors when initialising a voice connection. It does not account for errors that occur after the initial handshake (technically, because they are in IO and not ExceptT).

Instances

Instances details
Eq VoiceError Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

Show VoiceError Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

MonadError VoiceError Voice Source #

MonadError is for internal use, to propagate errors.

Instance details

Defined in Discord.Internal.Types.VoiceCommon

Methods

throwError :: VoiceError -> Voice a #

catchError :: Voice a -> (VoiceError -> Voice a) -> Voice a #

data SubprocessException Source #

SubprocessException is an Exception that may be thrown when a subprocess such as FFmpeg encounters an error.

TODO: This has never actually been seen, so it's untested whether it works.

data DiscordVoiceHandle Source #

DiscordVoiceHandle represents the handles for a single voice connection (to a specific voice channel).

Lenses are defined for this type using Template Haskell.

Constructors

DiscordVoiceHandle 

Fields

data DiscordBroadcastHandle Source #

DiscordBroadcastHandle represents a "stream" or a "broadcast", which is a mutable list of voice connection handles that share the same audio stream.

Lenses are defined for this type using Template Haskell.

Constructors

DiscordBroadcastHandle 

Fields

data WebsocketLaunchOpts Source #

WebsocketLaunchOpts represents all the data necessary to start a Websocket connection to Discord's Voice Gateway.

Lenses are defined for this type using Template Haskell.

Instances

Instances details
HasGuildId WebsocketLaunchOpts GuildId Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

HasToken WebsocketLaunchOpts Text Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

HasSessionId WebsocketLaunchOpts Text Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

HasEndpoint WebsocketLaunchOpts Text Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

HasBotUserId WebsocketLaunchOpts UserId Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

HasLaunchOpts WebsocketConn WebsocketLaunchOpts Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

HasSsrc WebsocketLaunchOpts (MVar Integer) Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

HasUdpTid WebsocketLaunchOpts (MVar (Weak ThreadId)) Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

HasWsHandle WebsocketLaunchOpts (VoiceWebsocketReceiveChan, VoiceWebsocketSendChan) Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

HasUdpHandle WebsocketLaunchOpts (VoiceUDPReceiveChan, VoiceUDPSendChan) Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

data WebsocketConn Source #

WebsocketConn represents an active connection to Discord's Voice Gateway websocket, and contains the Connection as well as the options that launched it.

Lenses are defined for this type using Template Haskell.

data UDPLaunchOpts Source #

UDPLaunchOpts represents all the data necessary to start a UDP connection to Discord. Field names for this ADT are cased weirdly because I want to keep the UDP part uppercase in the type and data constructor. Since field accessors are rarely used anyway (lenses are preferred instead), we can write the field prefixes as "uDP" and take advantage of Lenses as normal.

Lenses are defined for this type using Template Haskell.

data UDPConn Source #

UDPConn represents an active UDP connection to Discord, and contains the Socket as well as the options that launched it.

Lenses are defined for this type using Template Haskell.

class HasChannelId s a | s -> a where Source #

Methods

channelId :: Lens' s a Source #

class HasMutEx s a | s -> a where Source #

Methods

mutEx :: Lens' s a Source #

Instances

Instances details
HasMutEx DiscordBroadcastHandle (MVar ()) Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

class HasBotUserId s a | s -> a where Source #

Methods

botUserId :: Lens' s a Source #

class HasEndpoint s a | s -> a where Source #

Methods

endpoint :: Lens' s a Source #

class HasSessionId s a | s -> a where Source #

Methods

sessionId :: Lens' s a Source #

class HasToken s a | s -> a where Source #

Methods

token :: Lens' s a Source #

Instances

Instances details
HasToken WebsocketLaunchOpts Text Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

class HasUdpTid s a | s -> a where Source #

Methods

udpTid :: Lens' s a Source #

class HasConnection s a | s -> a where Source #

Methods

connection :: Lens' s a Source #

class HasIp s a | s -> a where Source #

Methods

ip :: Lens' s a Source #

Instances

Instances details
HasIp UDPLaunchOpts Text Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

class HasMode s a | s -> a where Source #

Methods

mode :: Lens' s a Source #

Instances

Instances details
HasMode UDPLaunchOpts Text Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

class HasPort s a | s -> a where Source #

Methods

port :: Lens' s a Source #

Instances

Instances details
HasPort UDPLaunchOpts Integer Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

class HasSecretKey s a | s -> a where Source #

Methods

secretKey :: Lens' s a Source #

Instances

Instances details
HasSecretKey UDPLaunchOpts (MVar [Word8]) Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon

class HasSocket s a | s -> a where Source #

Methods

socket :: Lens' s a Source #

Instances

Instances details
HasSocket UDPConn Socket Source # 
Instance details

Defined in Discord.Internal.Types.VoiceCommon