jsaddle-dom-0.10.0.0: src/JSDOM/Generated/RTCDataChannel.hs
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from webrtc (webref). Do not edit.
module JSDOM.Generated.RTCDataChannel
(close, send, send', send2, send3, getLabel, getOrdered, getMaxPacketLifeTime, getMaxPacketLifeTimeUnsafe, getMaxPacketLifeTimeUnchecked, getMaxRetransmits, getMaxRetransmitsUnsafe, getMaxRetransmitsUnchecked, getProtocol, getNegotiated, getId, getIdUnsafe, getIdUnchecked, getReadyState, getBufferedAmount, setBufferedAmountLowThreshold, getBufferedAmountLowThreshold, setBinaryType, getBinaryType, open, bufferedamountlow, error, closing, closeEvent, message, RTCDataChannel(..), gTypeRTCDataChannel)
where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/close MDN RTCDataChannel.close documentation>
close :: (MonadDOM m) => RTCDataChannel -> m ()
close self = liftDOM (void (self ^. jsf "close" ()))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/send MDN RTCDataChannel.send documentation>
send :: (MonadDOM m, ToJSString data') => RTCDataChannel -> data' -> m ()
send self data' = liftDOM (void (self ^. jsf "send" [toJSVal data']))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/send MDN RTCDataChannel.send documentation>
send' :: (MonadDOM m, IsBlob data') => RTCDataChannel -> data' -> m ()
send' self data' = liftDOM (void (self ^. jsf "send" [toJSVal data']))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/send MDN RTCDataChannel.send documentation>
send2 :: (MonadDOM m, IsArrayBuffer data') => RTCDataChannel -> data' -> m ()
send2 self data' = liftDOM (void (self ^. jsf "send" [toJSVal data']))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/send MDN RTCDataChannel.send documentation>
send3 :: (MonadDOM m, IsArrayBufferView data') => RTCDataChannel -> data' -> m ()
send3 self data' = liftDOM (void (self ^. jsf "send" [toJSVal data']))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/label MDN RTCDataChannel.label documentation>
getLabel :: (MonadDOM m, FromJSString result) => RTCDataChannel -> m result
getLabel self = liftDOM (((self ^. js "label") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/ordered MDN RTCDataChannel.ordered documentation>
getOrdered :: (MonadDOM m) => RTCDataChannel -> m Bool
getOrdered self = liftDOM (((self ^. js "ordered") >>= valToBool))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/maxPacketLifeTime MDN RTCDataChannel.maxPacketLifeTime documentation>
getMaxPacketLifeTime :: (MonadDOM m) => RTCDataChannel -> m (Maybe Word)
getMaxPacketLifeTime self = liftDOM (((self ^. js "maxPacketLifeTime") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/maxPacketLifeTime MDN RTCDataChannel.maxPacketLifeTime documentation>
getMaxPacketLifeTimeUnsafe :: (MonadDOM m, HasCallStack) => RTCDataChannel -> m Word
getMaxPacketLifeTimeUnsafe self = liftDOM ((((self ^. js "maxPacketLifeTime") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/maxPacketLifeTime MDN RTCDataChannel.maxPacketLifeTime documentation>
getMaxPacketLifeTimeUnchecked :: (MonadDOM m) => RTCDataChannel -> m Word
getMaxPacketLifeTimeUnchecked self = liftDOM ((P.round <$> ((self ^. js "maxPacketLifeTime") >>= valToNumber)))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/maxRetransmits MDN RTCDataChannel.maxRetransmits documentation>
getMaxRetransmits :: (MonadDOM m) => RTCDataChannel -> m (Maybe Word)
getMaxRetransmits self = liftDOM (((self ^. js "maxRetransmits") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/maxRetransmits MDN RTCDataChannel.maxRetransmits documentation>
getMaxRetransmitsUnsafe :: (MonadDOM m, HasCallStack) => RTCDataChannel -> m Word
getMaxRetransmitsUnsafe self = liftDOM ((((self ^. js "maxRetransmits") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/maxRetransmits MDN RTCDataChannel.maxRetransmits documentation>
getMaxRetransmitsUnchecked :: (MonadDOM m) => RTCDataChannel -> m Word
getMaxRetransmitsUnchecked self = liftDOM ((P.round <$> ((self ^. js "maxRetransmits") >>= valToNumber)))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/protocol MDN RTCDataChannel.protocol documentation>
getProtocol :: (MonadDOM m, FromJSString result) => RTCDataChannel -> m result
getProtocol self = liftDOM (((self ^. js "protocol") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/negotiated MDN RTCDataChannel.negotiated documentation>
getNegotiated :: (MonadDOM m) => RTCDataChannel -> m Bool
getNegotiated self = liftDOM (((self ^. js "negotiated") >>= valToBool))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/id MDN RTCDataChannel.id documentation>
getId :: (MonadDOM m) => RTCDataChannel -> m (Maybe Word)
getId self = liftDOM (((self ^. js "id") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/id MDN RTCDataChannel.id documentation>
getIdUnsafe :: (MonadDOM m, HasCallStack) => RTCDataChannel -> m Word
getIdUnsafe self = liftDOM ((((self ^. js "id") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/id MDN RTCDataChannel.id documentation>
getIdUnchecked :: (MonadDOM m) => RTCDataChannel -> m Word
getIdUnchecked self = liftDOM ((P.round <$> ((self ^. js "id") >>= valToNumber)))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/readyState MDN RTCDataChannel.readyState documentation>
getReadyState :: (MonadDOM m) => RTCDataChannel -> m RTCDataChannelState
getReadyState self = liftDOM (((self ^. js "readyState") >>= fromJSValUnchecked))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/bufferedAmount MDN RTCDataChannel.bufferedAmount documentation>
getBufferedAmount :: (MonadDOM m) => RTCDataChannel -> m Word
getBufferedAmount self = liftDOM ((P.round <$> ((self ^. js "bufferedAmount") >>= valToNumber)))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/bufferedAmountLowThreshold MDN RTCDataChannel.bufferedAmountLowThreshold documentation>
setBufferedAmountLowThreshold :: (MonadDOM m) => RTCDataChannel -> Word -> m ()
setBufferedAmountLowThreshold self val = liftDOM (void (self ^. jss "bufferedAmountLowThreshold" (toJSVal val)))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/bufferedAmountLowThreshold MDN RTCDataChannel.bufferedAmountLowThreshold documentation>
getBufferedAmountLowThreshold :: (MonadDOM m) => RTCDataChannel -> m Word
getBufferedAmountLowThreshold self = liftDOM ((P.round <$> ((self ^. js "bufferedAmountLowThreshold") >>= valToNumber)))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/binaryType MDN RTCDataChannel.binaryType documentation>
setBinaryType :: (MonadDOM m) => RTCDataChannel -> BinaryType -> m ()
setBinaryType self val = liftDOM (void (self ^. jss "binaryType" (toJSVal val)))
-- | <https://developer.mozilla.org/docs/Web/API/RTCDataChannel/binaryType MDN RTCDataChannel.binaryType documentation>
getBinaryType :: (MonadDOM m) => RTCDataChannel -> m BinaryType
getBinaryType self = liftDOM (((self ^. js "binaryType") >>= fromJSValUnchecked))
-- | <https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel-onopen open event>
open :: EventName RTCDataChannel Event
open = unsafeEventNameAsync (toJSString "open")
-- | <https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel-onbufferedamountlow bufferedamountlow event>
bufferedamountlow :: EventName RTCDataChannel Event
bufferedamountlow = unsafeEventName (toJSString "bufferedamountlow")
-- | <https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel-onerror error event>
error :: EventName RTCDataChannel RTCErrorEvent
error = unsafeEventNameAsync (toJSString "error")
-- | <https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel-onclosing closing event>
closing :: EventName RTCDataChannel Event
closing = unsafeEventName (toJSString "closing")
-- | <https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel-onclose close event>
closeEvent :: EventName RTCDataChannel Event
closeEvent = unsafeEventNameAsync (toJSString "close")
-- | <https://w3c.github.io/webrtc-pc/#dom-rtcdatachannel-onmessage message event>
message :: EventName RTCDataChannel MessageEvent
message = unsafeEventNameAsync (toJSString "message")