{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

A class representing a WebSocket connection.
-}

module GI.Soup.Objects.WebsocketConnection
    ( 

-- * Exported types
    WebsocketConnection(..)                 ,
    IsWebsocketConnection                   ,
    toWebsocketConnection                   ,
    noWebsocketConnection                   ,


 -- * Methods
-- ** close #method:close#
    WebsocketConnectionCloseMethodInfo      ,
    websocketConnectionClose                ,


-- ** getCloseCode #method:getCloseCode#
    WebsocketConnectionGetCloseCodeMethodInfo,
    websocketConnectionGetCloseCode         ,


-- ** getCloseData #method:getCloseData#
    WebsocketConnectionGetCloseDataMethodInfo,
    websocketConnectionGetCloseData         ,


-- ** getConnectionType #method:getConnectionType#
    WebsocketConnectionGetConnectionTypeMethodInfo,
    websocketConnectionGetConnectionType    ,


-- ** getIoStream #method:getIoStream#
    WebsocketConnectionGetIoStreamMethodInfo,
    websocketConnectionGetIoStream          ,


-- ** getMaxIncomingPayloadSize #method:getMaxIncomingPayloadSize#
    WebsocketConnectionGetMaxIncomingPayloadSizeMethodInfo,
    websocketConnectionGetMaxIncomingPayloadSize,


-- ** getOrigin #method:getOrigin#
    WebsocketConnectionGetOriginMethodInfo  ,
    websocketConnectionGetOrigin            ,


-- ** getProtocol #method:getProtocol#
    WebsocketConnectionGetProtocolMethodInfo,
    websocketConnectionGetProtocol          ,


-- ** getState #method:getState#
    WebsocketConnectionGetStateMethodInfo   ,
    websocketConnectionGetState             ,


-- ** getUri #method:getUri#
    WebsocketConnectionGetUriMethodInfo     ,
    websocketConnectionGetUri               ,


-- ** new #method:new#
    websocketConnectionNew                  ,


-- ** sendBinary #method:sendBinary#
    WebsocketConnectionSendBinaryMethodInfo ,
    websocketConnectionSendBinary           ,


-- ** sendText #method:sendText#
    WebsocketConnectionSendTextMethodInfo   ,
    websocketConnectionSendText             ,


-- ** setMaxIncomingPayloadSize #method:setMaxIncomingPayloadSize#
    WebsocketConnectionSetMaxIncomingPayloadSizeMethodInfo,
    websocketConnectionSetMaxIncomingPayloadSize,




 -- * Properties
-- ** connectionType #attr:connectionType#
    WebsocketConnectionConnectionTypePropertyInfo,
    constructWebsocketConnectionConnectionType,
    getWebsocketConnectionConnectionType    ,
    websocketConnectionConnectionType       ,


-- ** ioStream #attr:ioStream#
    WebsocketConnectionIoStreamPropertyInfo ,
    constructWebsocketConnectionIoStream    ,
    getWebsocketConnectionIoStream          ,
    websocketConnectionIoStream             ,


-- ** maxIncomingPayloadSize #attr:maxIncomingPayloadSize#
    WebsocketConnectionMaxIncomingPayloadSizePropertyInfo,
    constructWebsocketConnectionMaxIncomingPayloadSize,
    getWebsocketConnectionMaxIncomingPayloadSize,
    setWebsocketConnectionMaxIncomingPayloadSize,
    websocketConnectionMaxIncomingPayloadSize,


-- ** origin #attr:origin#
    WebsocketConnectionOriginPropertyInfo   ,
    constructWebsocketConnectionOrigin      ,
    getWebsocketConnectionOrigin            ,
    websocketConnectionOrigin               ,


-- ** protocol #attr:protocol#
    WebsocketConnectionProtocolPropertyInfo ,
    constructWebsocketConnectionProtocol    ,
    getWebsocketConnectionProtocol          ,
    websocketConnectionProtocol             ,


-- ** state #attr:state#
    WebsocketConnectionStatePropertyInfo    ,
    getWebsocketConnectionState             ,
    websocketConnectionState                ,


-- ** uri #attr:uri#
    WebsocketConnectionUriPropertyInfo      ,
    constructWebsocketConnectionUri         ,
    getWebsocketConnectionUri               ,
    websocketConnectionUri                  ,




 -- * Signals
-- ** closed #signal:closed#
    C_WebsocketConnectionClosedCallback     ,
    WebsocketConnectionClosedCallback       ,
    WebsocketConnectionClosedSignalInfo     ,
    afterWebsocketConnectionClosed          ,
    genClosure_WebsocketConnectionClosed    ,
    mk_WebsocketConnectionClosedCallback    ,
    noWebsocketConnectionClosedCallback     ,
    onWebsocketConnectionClosed             ,
    wrap_WebsocketConnectionClosedCallback  ,


-- ** closing #signal:closing#
    C_WebsocketConnectionClosingCallback    ,
    WebsocketConnectionClosingCallback      ,
    WebsocketConnectionClosingSignalInfo    ,
    afterWebsocketConnectionClosing         ,
    genClosure_WebsocketConnectionClosing   ,
    mk_WebsocketConnectionClosingCallback   ,
    noWebsocketConnectionClosingCallback    ,
    onWebsocketConnectionClosing            ,
    wrap_WebsocketConnectionClosingCallback ,


-- ** error #signal:error#
    C_WebsocketConnectionErrorCallback      ,
    WebsocketConnectionErrorCallback        ,
    WebsocketConnectionErrorSignalInfo      ,
    afterWebsocketConnectionError           ,
    genClosure_WebsocketConnectionError     ,
    mk_WebsocketConnectionErrorCallback     ,
    noWebsocketConnectionErrorCallback      ,
    onWebsocketConnectionError              ,
    wrap_WebsocketConnectionErrorCallback   ,


-- ** message #signal:message#
    C_WebsocketConnectionMessageCallback    ,
    WebsocketConnectionMessageCallback      ,
    WebsocketConnectionMessageSignalInfo    ,
    afterWebsocketConnectionMessage         ,
    genClosure_WebsocketConnectionMessage   ,
    mk_WebsocketConnectionMessageCallback   ,
    noWebsocketConnectionMessageCallback    ,
    onWebsocketConnectionMessage            ,
    wrap_WebsocketConnectionMessageCallback ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Objects.IOStream as Gio.IOStream
import {-# SOURCE #-} qualified GI.Soup.Enums as Soup.Enums
import {-# SOURCE #-} qualified GI.Soup.Structs.URI as Soup.URI

newtype WebsocketConnection = WebsocketConnection (ManagedPtr WebsocketConnection)
foreign import ccall "soup_websocket_connection_get_type"
    c_soup_websocket_connection_get_type :: IO GType

instance GObject WebsocketConnection where
    gobjectType _ = c_soup_websocket_connection_get_type
    

class GObject o => IsWebsocketConnection o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError WebsocketConnection a) =>
    IsWebsocketConnection a
#endif
instance IsWebsocketConnection WebsocketConnection
instance GObject.Object.IsObject WebsocketConnection

toWebsocketConnection :: IsWebsocketConnection o => o -> IO WebsocketConnection
toWebsocketConnection = unsafeCastTo WebsocketConnection

noWebsocketConnection :: Maybe WebsocketConnection
noWebsocketConnection = Nothing

type family ResolveWebsocketConnectionMethod (t :: Symbol) (o :: *) :: * where
    ResolveWebsocketConnectionMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveWebsocketConnectionMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveWebsocketConnectionMethod "close" o = WebsocketConnectionCloseMethodInfo
    ResolveWebsocketConnectionMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveWebsocketConnectionMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveWebsocketConnectionMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveWebsocketConnectionMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveWebsocketConnectionMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveWebsocketConnectionMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveWebsocketConnectionMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveWebsocketConnectionMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveWebsocketConnectionMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveWebsocketConnectionMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveWebsocketConnectionMethod "sendBinary" o = WebsocketConnectionSendBinaryMethodInfo
    ResolveWebsocketConnectionMethod "sendText" o = WebsocketConnectionSendTextMethodInfo
    ResolveWebsocketConnectionMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveWebsocketConnectionMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveWebsocketConnectionMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveWebsocketConnectionMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveWebsocketConnectionMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveWebsocketConnectionMethod "getCloseCode" o = WebsocketConnectionGetCloseCodeMethodInfo
    ResolveWebsocketConnectionMethod "getCloseData" o = WebsocketConnectionGetCloseDataMethodInfo
    ResolveWebsocketConnectionMethod "getConnectionType" o = WebsocketConnectionGetConnectionTypeMethodInfo
    ResolveWebsocketConnectionMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveWebsocketConnectionMethod "getIoStream" o = WebsocketConnectionGetIoStreamMethodInfo
    ResolveWebsocketConnectionMethod "getMaxIncomingPayloadSize" o = WebsocketConnectionGetMaxIncomingPayloadSizeMethodInfo
    ResolveWebsocketConnectionMethod "getOrigin" o = WebsocketConnectionGetOriginMethodInfo
    ResolveWebsocketConnectionMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveWebsocketConnectionMethod "getProtocol" o = WebsocketConnectionGetProtocolMethodInfo
    ResolveWebsocketConnectionMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveWebsocketConnectionMethod "getState" o = WebsocketConnectionGetStateMethodInfo
    ResolveWebsocketConnectionMethod "getUri" o = WebsocketConnectionGetUriMethodInfo
    ResolveWebsocketConnectionMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveWebsocketConnectionMethod "setMaxIncomingPayloadSize" o = WebsocketConnectionSetMaxIncomingPayloadSizeMethodInfo
    ResolveWebsocketConnectionMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveWebsocketConnectionMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveWebsocketConnectionMethod t WebsocketConnection, O.MethodInfo info WebsocketConnection p) => O.IsLabelProxy t (WebsocketConnection -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveWebsocketConnectionMethod t WebsocketConnection, O.MethodInfo info WebsocketConnection p) => O.IsLabel t (WebsocketConnection -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal WebsocketConnection::closed
type WebsocketConnectionClosedCallback =
    IO ()

noWebsocketConnectionClosedCallback :: Maybe WebsocketConnectionClosedCallback
noWebsocketConnectionClosedCallback = Nothing

type C_WebsocketConnectionClosedCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_WebsocketConnectionClosedCallback :: C_WebsocketConnectionClosedCallback -> IO (FunPtr C_WebsocketConnectionClosedCallback)

genClosure_WebsocketConnectionClosed :: WebsocketConnectionClosedCallback -> IO Closure
genClosure_WebsocketConnectionClosed cb = do
    let cb' = wrap_WebsocketConnectionClosedCallback cb
    mk_WebsocketConnectionClosedCallback cb' >>= newCClosure


wrap_WebsocketConnectionClosedCallback ::
    WebsocketConnectionClosedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_WebsocketConnectionClosedCallback _cb _ _ = do
    _cb 


onWebsocketConnectionClosed :: (GObject a, MonadIO m) => a -> WebsocketConnectionClosedCallback -> m SignalHandlerId
onWebsocketConnectionClosed obj cb = liftIO $ connectWebsocketConnectionClosed obj cb SignalConnectBefore
afterWebsocketConnectionClosed :: (GObject a, MonadIO m) => a -> WebsocketConnectionClosedCallback -> m SignalHandlerId
afterWebsocketConnectionClosed obj cb = connectWebsocketConnectionClosed obj cb SignalConnectAfter

connectWebsocketConnectionClosed :: (GObject a, MonadIO m) =>
                                    a -> WebsocketConnectionClosedCallback -> SignalConnectMode -> m SignalHandlerId
connectWebsocketConnectionClosed obj cb after = liftIO $ do
    let cb' = wrap_WebsocketConnectionClosedCallback cb
    cb'' <- mk_WebsocketConnectionClosedCallback cb'
    connectSignalFunPtr obj "closed" cb'' after

-- signal WebsocketConnection::closing
type WebsocketConnectionClosingCallback =
    IO ()

noWebsocketConnectionClosingCallback :: Maybe WebsocketConnectionClosingCallback
noWebsocketConnectionClosingCallback = Nothing

type C_WebsocketConnectionClosingCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_WebsocketConnectionClosingCallback :: C_WebsocketConnectionClosingCallback -> IO (FunPtr C_WebsocketConnectionClosingCallback)

genClosure_WebsocketConnectionClosing :: WebsocketConnectionClosingCallback -> IO Closure
genClosure_WebsocketConnectionClosing cb = do
    let cb' = wrap_WebsocketConnectionClosingCallback cb
    mk_WebsocketConnectionClosingCallback cb' >>= newCClosure


wrap_WebsocketConnectionClosingCallback ::
    WebsocketConnectionClosingCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_WebsocketConnectionClosingCallback _cb _ _ = do
    _cb 


onWebsocketConnectionClosing :: (GObject a, MonadIO m) => a -> WebsocketConnectionClosingCallback -> m SignalHandlerId
onWebsocketConnectionClosing obj cb = liftIO $ connectWebsocketConnectionClosing obj cb SignalConnectBefore
afterWebsocketConnectionClosing :: (GObject a, MonadIO m) => a -> WebsocketConnectionClosingCallback -> m SignalHandlerId
afterWebsocketConnectionClosing obj cb = connectWebsocketConnectionClosing obj cb SignalConnectAfter

connectWebsocketConnectionClosing :: (GObject a, MonadIO m) =>
                                     a -> WebsocketConnectionClosingCallback -> SignalConnectMode -> m SignalHandlerId
connectWebsocketConnectionClosing obj cb after = liftIO $ do
    let cb' = wrap_WebsocketConnectionClosingCallback cb
    cb'' <- mk_WebsocketConnectionClosingCallback cb'
    connectSignalFunPtr obj "closing" cb'' after

-- signal WebsocketConnection::error
type WebsocketConnectionErrorCallback =
    GError ->
    IO ()

noWebsocketConnectionErrorCallback :: Maybe WebsocketConnectionErrorCallback
noWebsocketConnectionErrorCallback = Nothing

type C_WebsocketConnectionErrorCallback =
    Ptr () ->                               -- object
    Ptr GError ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_WebsocketConnectionErrorCallback :: C_WebsocketConnectionErrorCallback -> IO (FunPtr C_WebsocketConnectionErrorCallback)

genClosure_WebsocketConnectionError :: WebsocketConnectionErrorCallback -> IO Closure
genClosure_WebsocketConnectionError cb = do
    let cb' = wrap_WebsocketConnectionErrorCallback cb
    mk_WebsocketConnectionErrorCallback cb' >>= newCClosure


wrap_WebsocketConnectionErrorCallback ::
    WebsocketConnectionErrorCallback ->
    Ptr () ->
    Ptr GError ->
    Ptr () ->
    IO ()
wrap_WebsocketConnectionErrorCallback _cb _ error_ _ = do
    error_' <- (newBoxed GError) error_
    _cb  error_'


onWebsocketConnectionError :: (GObject a, MonadIO m) => a -> WebsocketConnectionErrorCallback -> m SignalHandlerId
onWebsocketConnectionError obj cb = liftIO $ connectWebsocketConnectionError obj cb SignalConnectBefore
afterWebsocketConnectionError :: (GObject a, MonadIO m) => a -> WebsocketConnectionErrorCallback -> m SignalHandlerId
afterWebsocketConnectionError obj cb = connectWebsocketConnectionError obj cb SignalConnectAfter

connectWebsocketConnectionError :: (GObject a, MonadIO m) =>
                                   a -> WebsocketConnectionErrorCallback -> SignalConnectMode -> m SignalHandlerId
connectWebsocketConnectionError obj cb after = liftIO $ do
    let cb' = wrap_WebsocketConnectionErrorCallback cb
    cb'' <- mk_WebsocketConnectionErrorCallback cb'
    connectSignalFunPtr obj "error" cb'' after

-- signal WebsocketConnection::message
type WebsocketConnectionMessageCallback =
    Int32 ->
    GLib.Bytes.Bytes ->
    IO ()

noWebsocketConnectionMessageCallback :: Maybe WebsocketConnectionMessageCallback
noWebsocketConnectionMessageCallback = Nothing

type C_WebsocketConnectionMessageCallback =
    Ptr () ->                               -- object
    Int32 ->
    Ptr GLib.Bytes.Bytes ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_WebsocketConnectionMessageCallback :: C_WebsocketConnectionMessageCallback -> IO (FunPtr C_WebsocketConnectionMessageCallback)

genClosure_WebsocketConnectionMessage :: WebsocketConnectionMessageCallback -> IO Closure
genClosure_WebsocketConnectionMessage cb = do
    let cb' = wrap_WebsocketConnectionMessageCallback cb
    mk_WebsocketConnectionMessageCallback cb' >>= newCClosure


wrap_WebsocketConnectionMessageCallback ::
    WebsocketConnectionMessageCallback ->
    Ptr () ->
    Int32 ->
    Ptr GLib.Bytes.Bytes ->
    Ptr () ->
    IO ()
wrap_WebsocketConnectionMessageCallback _cb _ type_ message _ = do
    message' <- (newBoxed GLib.Bytes.Bytes) message
    _cb  type_ message'


onWebsocketConnectionMessage :: (GObject a, MonadIO m) => a -> WebsocketConnectionMessageCallback -> m SignalHandlerId
onWebsocketConnectionMessage obj cb = liftIO $ connectWebsocketConnectionMessage obj cb SignalConnectBefore
afterWebsocketConnectionMessage :: (GObject a, MonadIO m) => a -> WebsocketConnectionMessageCallback -> m SignalHandlerId
afterWebsocketConnectionMessage obj cb = connectWebsocketConnectionMessage obj cb SignalConnectAfter

connectWebsocketConnectionMessage :: (GObject a, MonadIO m) =>
                                     a -> WebsocketConnectionMessageCallback -> SignalConnectMode -> m SignalHandlerId
connectWebsocketConnectionMessage obj cb after = liftIO $ do
    let cb' = wrap_WebsocketConnectionMessageCallback cb
    cb'' <- mk_WebsocketConnectionMessageCallback cb'
    connectSignalFunPtr obj "message" cb'' after

-- VVV Prop "connection-type"
   -- Type: TInterface (Name {namespace = "Soup", name = "WebsocketConnectionType"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getWebsocketConnectionConnectionType :: (MonadIO m, IsWebsocketConnection o) => o -> m Soup.Enums.WebsocketConnectionType
getWebsocketConnectionConnectionType obj = liftIO $ getObjectPropertyEnum obj "connection-type"

constructWebsocketConnectionConnectionType :: (IsWebsocketConnection o) => Soup.Enums.WebsocketConnectionType -> IO (GValueConstruct o)
constructWebsocketConnectionConnectionType val = constructObjectPropertyEnum "connection-type" val

data WebsocketConnectionConnectionTypePropertyInfo
instance AttrInfo WebsocketConnectionConnectionTypePropertyInfo where
    type AttrAllowedOps WebsocketConnectionConnectionTypePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebsocketConnectionConnectionTypePropertyInfo = (~) Soup.Enums.WebsocketConnectionType
    type AttrBaseTypeConstraint WebsocketConnectionConnectionTypePropertyInfo = IsWebsocketConnection
    type AttrGetType WebsocketConnectionConnectionTypePropertyInfo = Soup.Enums.WebsocketConnectionType
    type AttrLabel WebsocketConnectionConnectionTypePropertyInfo = "connection-type"
    type AttrOrigin WebsocketConnectionConnectionTypePropertyInfo = WebsocketConnection
    attrGet _ = getWebsocketConnectionConnectionType
    attrSet _ = undefined
    attrConstruct _ = constructWebsocketConnectionConnectionType
    attrClear _ = undefined

-- VVV Prop "io-stream"
   -- Type: TInterface (Name {namespace = "Gio", name = "IOStream"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getWebsocketConnectionIoStream :: (MonadIO m, IsWebsocketConnection o) => o -> m Gio.IOStream.IOStream
getWebsocketConnectionIoStream obj = liftIO $ checkUnexpectedNothing "getWebsocketConnectionIoStream" $ getObjectPropertyObject obj "io-stream" Gio.IOStream.IOStream

constructWebsocketConnectionIoStream :: (IsWebsocketConnection o, Gio.IOStream.IsIOStream a) => a -> IO (GValueConstruct o)
constructWebsocketConnectionIoStream val = constructObjectPropertyObject "io-stream" (Just val)

data WebsocketConnectionIoStreamPropertyInfo
instance AttrInfo WebsocketConnectionIoStreamPropertyInfo where
    type AttrAllowedOps WebsocketConnectionIoStreamPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint WebsocketConnectionIoStreamPropertyInfo = Gio.IOStream.IsIOStream
    type AttrBaseTypeConstraint WebsocketConnectionIoStreamPropertyInfo = IsWebsocketConnection
    type AttrGetType WebsocketConnectionIoStreamPropertyInfo = Gio.IOStream.IOStream
    type AttrLabel WebsocketConnectionIoStreamPropertyInfo = "io-stream"
    type AttrOrigin WebsocketConnectionIoStreamPropertyInfo = WebsocketConnection
    attrGet _ = getWebsocketConnectionIoStream
    attrSet _ = undefined
    attrConstruct _ = constructWebsocketConnectionIoStream
    attrClear _ = undefined

-- VVV Prop "max-incoming-payload-size"
   -- Type: TBasicType TUInt64
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just False,Just False)

getWebsocketConnectionMaxIncomingPayloadSize :: (MonadIO m, IsWebsocketConnection o) => o -> m Word64
getWebsocketConnectionMaxIncomingPayloadSize obj = liftIO $ getObjectPropertyUInt64 obj "max-incoming-payload-size"

setWebsocketConnectionMaxIncomingPayloadSize :: (MonadIO m, IsWebsocketConnection o) => o -> Word64 -> m ()
setWebsocketConnectionMaxIncomingPayloadSize obj val = liftIO $ setObjectPropertyUInt64 obj "max-incoming-payload-size" val

constructWebsocketConnectionMaxIncomingPayloadSize :: (IsWebsocketConnection o) => Word64 -> IO (GValueConstruct o)
constructWebsocketConnectionMaxIncomingPayloadSize val = constructObjectPropertyUInt64 "max-incoming-payload-size" val

data WebsocketConnectionMaxIncomingPayloadSizePropertyInfo
instance AttrInfo WebsocketConnectionMaxIncomingPayloadSizePropertyInfo where
    type AttrAllowedOps WebsocketConnectionMaxIncomingPayloadSizePropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebsocketConnectionMaxIncomingPayloadSizePropertyInfo = (~) Word64
    type AttrBaseTypeConstraint WebsocketConnectionMaxIncomingPayloadSizePropertyInfo = IsWebsocketConnection
    type AttrGetType WebsocketConnectionMaxIncomingPayloadSizePropertyInfo = Word64
    type AttrLabel WebsocketConnectionMaxIncomingPayloadSizePropertyInfo = "max-incoming-payload-size"
    type AttrOrigin WebsocketConnectionMaxIncomingPayloadSizePropertyInfo = WebsocketConnection
    attrGet _ = getWebsocketConnectionMaxIncomingPayloadSize
    attrSet _ = setWebsocketConnectionMaxIncomingPayloadSize
    attrConstruct _ = constructWebsocketConnectionMaxIncomingPayloadSize
    attrClear _ = undefined

-- VVV Prop "origin"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just True,Nothing)

getWebsocketConnectionOrigin :: (MonadIO m, IsWebsocketConnection o) => o -> m (Maybe T.Text)
getWebsocketConnectionOrigin obj = liftIO $ getObjectPropertyString obj "origin"

constructWebsocketConnectionOrigin :: (IsWebsocketConnection o) => T.Text -> IO (GValueConstruct o)
constructWebsocketConnectionOrigin val = constructObjectPropertyString "origin" (Just val)

data WebsocketConnectionOriginPropertyInfo
instance AttrInfo WebsocketConnectionOriginPropertyInfo where
    type AttrAllowedOps WebsocketConnectionOriginPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint WebsocketConnectionOriginPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint WebsocketConnectionOriginPropertyInfo = IsWebsocketConnection
    type AttrGetType WebsocketConnectionOriginPropertyInfo = (Maybe T.Text)
    type AttrLabel WebsocketConnectionOriginPropertyInfo = "origin"
    type AttrOrigin WebsocketConnectionOriginPropertyInfo = WebsocketConnection
    attrGet _ = getWebsocketConnectionOrigin
    attrSet _ = undefined
    attrConstruct _ = constructWebsocketConnectionOrigin
    attrClear _ = undefined

-- VVV Prop "protocol"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just True,Nothing)

getWebsocketConnectionProtocol :: (MonadIO m, IsWebsocketConnection o) => o -> m (Maybe T.Text)
getWebsocketConnectionProtocol obj = liftIO $ getObjectPropertyString obj "protocol"

constructWebsocketConnectionProtocol :: (IsWebsocketConnection o) => T.Text -> IO (GValueConstruct o)
constructWebsocketConnectionProtocol val = constructObjectPropertyString "protocol" (Just val)

data WebsocketConnectionProtocolPropertyInfo
instance AttrInfo WebsocketConnectionProtocolPropertyInfo where
    type AttrAllowedOps WebsocketConnectionProtocolPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint WebsocketConnectionProtocolPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint WebsocketConnectionProtocolPropertyInfo = IsWebsocketConnection
    type AttrGetType WebsocketConnectionProtocolPropertyInfo = (Maybe T.Text)
    type AttrLabel WebsocketConnectionProtocolPropertyInfo = "protocol"
    type AttrOrigin WebsocketConnectionProtocolPropertyInfo = WebsocketConnection
    attrGet _ = getWebsocketConnectionProtocol
    attrSet _ = undefined
    attrConstruct _ = constructWebsocketConnectionProtocol
    attrClear _ = undefined

-- VVV Prop "state"
   -- Type: TInterface (Name {namespace = "Soup", name = "WebsocketState"})
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getWebsocketConnectionState :: (MonadIO m, IsWebsocketConnection o) => o -> m Soup.Enums.WebsocketState
getWebsocketConnectionState obj = liftIO $ getObjectPropertyEnum obj "state"

data WebsocketConnectionStatePropertyInfo
instance AttrInfo WebsocketConnectionStatePropertyInfo where
    type AttrAllowedOps WebsocketConnectionStatePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint WebsocketConnectionStatePropertyInfo = (~) ()
    type AttrBaseTypeConstraint WebsocketConnectionStatePropertyInfo = IsWebsocketConnection
    type AttrGetType WebsocketConnectionStatePropertyInfo = Soup.Enums.WebsocketState
    type AttrLabel WebsocketConnectionStatePropertyInfo = "state"
    type AttrOrigin WebsocketConnectionStatePropertyInfo = WebsocketConnection
    attrGet _ = getWebsocketConnectionState
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "uri"
   -- Type: TInterface (Name {namespace = "Soup", name = "URI"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getWebsocketConnectionUri :: (MonadIO m, IsWebsocketConnection o) => o -> m Soup.URI.URI
getWebsocketConnectionUri obj = liftIO $ checkUnexpectedNothing "getWebsocketConnectionUri" $ getObjectPropertyBoxed obj "uri" Soup.URI.URI

constructWebsocketConnectionUri :: (IsWebsocketConnection o) => Soup.URI.URI -> IO (GValueConstruct o)
constructWebsocketConnectionUri val = constructObjectPropertyBoxed "uri" (Just val)

data WebsocketConnectionUriPropertyInfo
instance AttrInfo WebsocketConnectionUriPropertyInfo where
    type AttrAllowedOps WebsocketConnectionUriPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint WebsocketConnectionUriPropertyInfo = (~) Soup.URI.URI
    type AttrBaseTypeConstraint WebsocketConnectionUriPropertyInfo = IsWebsocketConnection
    type AttrGetType WebsocketConnectionUriPropertyInfo = Soup.URI.URI
    type AttrLabel WebsocketConnectionUriPropertyInfo = "uri"
    type AttrOrigin WebsocketConnectionUriPropertyInfo = WebsocketConnection
    attrGet _ = getWebsocketConnectionUri
    attrSet _ = undefined
    attrConstruct _ = constructWebsocketConnectionUri
    attrClear _ = undefined

instance O.HasAttributeList WebsocketConnection
type instance O.AttributeList WebsocketConnection = WebsocketConnectionAttributeList
type WebsocketConnectionAttributeList = ('[ '("connectionType", WebsocketConnectionConnectionTypePropertyInfo), '("ioStream", WebsocketConnectionIoStreamPropertyInfo), '("maxIncomingPayloadSize", WebsocketConnectionMaxIncomingPayloadSizePropertyInfo), '("origin", WebsocketConnectionOriginPropertyInfo), '("protocol", WebsocketConnectionProtocolPropertyInfo), '("state", WebsocketConnectionStatePropertyInfo), '("uri", WebsocketConnectionUriPropertyInfo)] :: [(Symbol, *)])

websocketConnectionConnectionType :: AttrLabelProxy "connectionType"
websocketConnectionConnectionType = AttrLabelProxy

websocketConnectionIoStream :: AttrLabelProxy "ioStream"
websocketConnectionIoStream = AttrLabelProxy

websocketConnectionMaxIncomingPayloadSize :: AttrLabelProxy "maxIncomingPayloadSize"
websocketConnectionMaxIncomingPayloadSize = AttrLabelProxy

websocketConnectionOrigin :: AttrLabelProxy "origin"
websocketConnectionOrigin = AttrLabelProxy

websocketConnectionProtocol :: AttrLabelProxy "protocol"
websocketConnectionProtocol = AttrLabelProxy

websocketConnectionState :: AttrLabelProxy "state"
websocketConnectionState = AttrLabelProxy

websocketConnectionUri :: AttrLabelProxy "uri"
websocketConnectionUri = AttrLabelProxy

data WebsocketConnectionClosedSignalInfo
instance SignalInfo WebsocketConnectionClosedSignalInfo where
    type HaskellCallbackType WebsocketConnectionClosedSignalInfo = WebsocketConnectionClosedCallback
    connectSignal _ = connectWebsocketConnectionClosed

data WebsocketConnectionClosingSignalInfo
instance SignalInfo WebsocketConnectionClosingSignalInfo where
    type HaskellCallbackType WebsocketConnectionClosingSignalInfo = WebsocketConnectionClosingCallback
    connectSignal _ = connectWebsocketConnectionClosing

data WebsocketConnectionErrorSignalInfo
instance SignalInfo WebsocketConnectionErrorSignalInfo where
    type HaskellCallbackType WebsocketConnectionErrorSignalInfo = WebsocketConnectionErrorCallback
    connectSignal _ = connectWebsocketConnectionError

data WebsocketConnectionMessageSignalInfo
instance SignalInfo WebsocketConnectionMessageSignalInfo where
    type HaskellCallbackType WebsocketConnectionMessageSignalInfo = WebsocketConnectionMessageCallback
    connectSignal _ = connectWebsocketConnectionMessage

type instance O.SignalList WebsocketConnection = WebsocketConnectionSignalList
type WebsocketConnectionSignalList = ('[ '("closed", WebsocketConnectionClosedSignalInfo), '("closing", WebsocketConnectionClosingSignalInfo), '("error", WebsocketConnectionErrorSignalInfo), '("message", WebsocketConnectionMessageSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method WebsocketConnection::new
-- method type : Constructor
-- Args : [Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "IOStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIOStream connected to the WebSocket server", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "uri", argType = TInterface (Name {namespace = "Soup", name = "URI"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the URI of the connection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "type", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnectionType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the type of connection (client/side)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the Origin of the client", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "protocol", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the subprotocol in use", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_new" soup_websocket_connection_new :: 
    Ptr Gio.IOStream.IOStream ->            -- stream : TInterface (Name {namespace = "Gio", name = "IOStream"})
    Ptr Soup.URI.URI ->                     -- uri : TInterface (Name {namespace = "Soup", name = "URI"})
    CUInt ->                                -- type : TInterface (Name {namespace = "Soup", name = "WebsocketConnectionType"})
    CString ->                              -- origin : TBasicType TUTF8
    CString ->                              -- protocol : TBasicType TUTF8
    IO (Ptr WebsocketConnection)

{- |
Creates a 'GI.Soup.Objects.WebsocketConnection.WebsocketConnection' on /@stream@/. This should be
called after completing the handshake to begin using the WebSocket
protocol.

@since 2.50
-}
websocketConnectionNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.IOStream.IsIOStream a) =>
    a
    {- ^ /@stream@/: a 'GI.Gio.Objects.IOStream.IOStream' connected to the WebSocket server -}
    -> Soup.URI.URI
    {- ^ /@uri@/: the URI of the connection -}
    -> Soup.Enums.WebsocketConnectionType
    {- ^ /@type@/: the type of connection (client\/side) -}
    -> Maybe (T.Text)
    {- ^ /@origin@/: the Origin of the client -}
    -> Maybe (T.Text)
    {- ^ /@protocol@/: the subprotocol in use -}
    -> m WebsocketConnection
    {- ^ __Returns:__ a new 'GI.Soup.Objects.WebsocketConnection.WebsocketConnection' -}
websocketConnectionNew stream uri type_ origin protocol = liftIO $ do
    stream' <- unsafeManagedPtrCastPtr stream
    uri' <- unsafeManagedPtrGetPtr uri
    let type_' = (fromIntegral . fromEnum) type_
    maybeOrigin <- case origin of
        Nothing -> return nullPtr
        Just jOrigin -> do
            jOrigin' <- textToCString jOrigin
            return jOrigin'
    maybeProtocol <- case protocol of
        Nothing -> return nullPtr
        Just jProtocol -> do
            jProtocol' <- textToCString jProtocol
            return jProtocol'
    result <- soup_websocket_connection_new stream' uri' type_' maybeOrigin maybeProtocol
    checkUnexpectedReturnNULL "websocketConnectionNew" result
    result' <- (wrapObject WebsocketConnection) result
    touchManagedPtr stream
    touchManagedPtr uri
    freeMem maybeOrigin
    freeMem maybeProtocol
    return result'

-- method WebsocketConnection::close
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "code", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "close code", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "close data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_close" soup_websocket_connection_close :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    Word16 ->                               -- code : TBasicType TUInt16
    CString ->                              -- data : TBasicType TUTF8
    IO ()

{- |
Close the connection in an orderly fashion.

Note that until the 'GI.Soup.Objects.WebsocketConnection.WebsocketConnection'::@/closed/@ signal fires, the connection
is not yet completely closed. The close message is not even sent until the
main loop runs.

The /@code@/ and /@data@/ are sent to the peer along with the close request.
Note that the /@data@/ must be UTF-8 valid.

@since 2.50
-}
websocketConnectionClose ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> Word16
    {- ^ /@code@/: close code -}
    -> Maybe (T.Text)
    {- ^ /@data@/: close data -}
    -> m ()
websocketConnectionClose self code data_ = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    maybeData_ <- case data_ of
        Nothing -> return nullPtr
        Just jData_ -> do
            jData_' <- textToCString jData_
            return jData_'
    soup_websocket_connection_close self' code maybeData_
    touchManagedPtr self
    freeMem maybeData_
    return ()

data WebsocketConnectionCloseMethodInfo
instance (signature ~ (Word16 -> Maybe (T.Text) -> m ()), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionCloseMethodInfo a signature where
    overloadedMethod _ = websocketConnectionClose

-- method WebsocketConnection::get_close_code
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt16)
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_get_close_code" soup_websocket_connection_get_close_code :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    IO Word16

{- |
Get the close code received from the WebSocket peer.

This only becomes valid once the WebSocket is in the
'GI.Soup.Enums.WebsocketStateClosed' state. The value will often be in the
'GI.Soup.Enums.WebsocketCloseCode' enumeration, but may also be an application
defined close code.

@since 2.50
-}
websocketConnectionGetCloseCode ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> m Word16
    {- ^ __Returns:__ the close code or zero. -}
websocketConnectionGetCloseCode self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- soup_websocket_connection_get_close_code self'
    touchManagedPtr self
    return result

data WebsocketConnectionGetCloseCodeMethodInfo
instance (signature ~ (m Word16), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionGetCloseCodeMethodInfo a signature where
    overloadedMethod _ = websocketConnectionGetCloseCode

-- method WebsocketConnection::get_close_data
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_get_close_data" soup_websocket_connection_get_close_data :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    IO CString

{- |
Get the close data received from the WebSocket peer.

This only becomes valid once the WebSocket is in the
'GI.Soup.Enums.WebsocketStateClosed' state. The data may be freed once
the main loop is run, so copy it if you need to keep it around.

@since 2.50
-}
websocketConnectionGetCloseData ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> m T.Text
    {- ^ __Returns:__ the close data or 'Nothing' -}
websocketConnectionGetCloseData self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- soup_websocket_connection_get_close_data self'
    checkUnexpectedReturnNULL "websocketConnectionGetCloseData" result
    result' <- cstringToText result
    touchManagedPtr self
    return result'

data WebsocketConnectionGetCloseDataMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionGetCloseDataMethodInfo a signature where
    overloadedMethod _ = websocketConnectionGetCloseData

-- method WebsocketConnection::get_connection_type
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "WebsocketConnectionType"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_get_connection_type" soup_websocket_connection_get_connection_type :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    IO CUInt

{- |
Get the connection type (client\/server) of the connection.

@since 2.50
-}
websocketConnectionGetConnectionType ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> m Soup.Enums.WebsocketConnectionType
    {- ^ __Returns:__ the connection type -}
websocketConnectionGetConnectionType self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- soup_websocket_connection_get_connection_type self'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr self
    return result'

data WebsocketConnectionGetConnectionTypeMethodInfo
instance (signature ~ (m Soup.Enums.WebsocketConnectionType), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionGetConnectionTypeMethodInfo a signature where
    overloadedMethod _ = websocketConnectionGetConnectionType

-- method WebsocketConnection::get_io_stream
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "IOStream"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_get_io_stream" soup_websocket_connection_get_io_stream :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    IO (Ptr Gio.IOStream.IOStream)

{- |
Get the I\/O stream the WebSocket is communicating over.

@since 2.50
-}
websocketConnectionGetIoStream ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> m Gio.IOStream.IOStream
    {- ^ __Returns:__ the WebSocket\'s I\/O stream. -}
websocketConnectionGetIoStream self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- soup_websocket_connection_get_io_stream self'
    checkUnexpectedReturnNULL "websocketConnectionGetIoStream" result
    result' <- (newObject Gio.IOStream.IOStream) result
    touchManagedPtr self
    return result'

data WebsocketConnectionGetIoStreamMethodInfo
instance (signature ~ (m Gio.IOStream.IOStream), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionGetIoStreamMethodInfo a signature where
    overloadedMethod _ = websocketConnectionGetIoStream

-- method WebsocketConnection::get_max_incoming_payload_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_get_max_incoming_payload_size" soup_websocket_connection_get_max_incoming_payload_size :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    IO Word64

{- |
Gets the maximum payload size allowed for incoming packets.

@since 2.56
-}
websocketConnectionGetMaxIncomingPayloadSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> m Word64
    {- ^ __Returns:__ the maximum payload size. -}
websocketConnectionGetMaxIncomingPayloadSize self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- soup_websocket_connection_get_max_incoming_payload_size self'
    touchManagedPtr self
    return result

data WebsocketConnectionGetMaxIncomingPayloadSizeMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionGetMaxIncomingPayloadSizeMethodInfo a signature where
    overloadedMethod _ = websocketConnectionGetMaxIncomingPayloadSize

-- method WebsocketConnection::get_origin
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_get_origin" soup_websocket_connection_get_origin :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    IO CString

{- |
Get the origin of the WebSocket.

@since 2.50
-}
websocketConnectionGetOrigin ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the origin, or 'Nothing' -}
websocketConnectionGetOrigin self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- soup_websocket_connection_get_origin self'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr self
    return maybeResult

data WebsocketConnectionGetOriginMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionGetOriginMethodInfo a signature where
    overloadedMethod _ = websocketConnectionGetOrigin

-- method WebsocketConnection::get_protocol
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_get_protocol" soup_websocket_connection_get_protocol :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    IO CString

{- |
Get the protocol chosen via negotiation with the peer.

@since 2.50
-}
websocketConnectionGetProtocol ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the chosen protocol, or 'Nothing' -}
websocketConnectionGetProtocol self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- soup_websocket_connection_get_protocol self'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- cstringToText result'
        return result''
    touchManagedPtr self
    return maybeResult

data WebsocketConnectionGetProtocolMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionGetProtocolMethodInfo a signature where
    overloadedMethod _ = websocketConnectionGetProtocol

-- method WebsocketConnection::get_state
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "WebsocketState"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_get_state" soup_websocket_connection_get_state :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    IO CUInt

{- |
Get the current state of the WebSocket.

@since 2.50
-}
websocketConnectionGetState ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> m Soup.Enums.WebsocketState
    {- ^ __Returns:__ the state -}
websocketConnectionGetState self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- soup_websocket_connection_get_state self'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr self
    return result'

data WebsocketConnectionGetStateMethodInfo
instance (signature ~ (m Soup.Enums.WebsocketState), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionGetStateMethodInfo a signature where
    overloadedMethod _ = websocketConnectionGetState

-- method WebsocketConnection::get_uri
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "URI"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_get_uri" soup_websocket_connection_get_uri :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    IO (Ptr Soup.URI.URI)

{- |
Get the URI of the WebSocket.

For servers this represents the address of the WebSocket, and
for clients it is the address connected to.

@since 2.50
-}
websocketConnectionGetUri ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> m Soup.URI.URI
    {- ^ __Returns:__ the URI -}
websocketConnectionGetUri self = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    result <- soup_websocket_connection_get_uri self'
    checkUnexpectedReturnNULL "websocketConnectionGetUri" result
    result' <- (newBoxed Soup.URI.URI) result
    touchManagedPtr self
    return result'

data WebsocketConnectionGetUriMethodInfo
instance (signature ~ (m Soup.URI.URI), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionGetUriMethodInfo a signature where
    overloadedMethod _ = websocketConnectionGetUri

-- method WebsocketConnection::send_binary
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message contents", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : [Arg {argCName = "length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of @data", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_send_binary" soup_websocket_connection_send_binary :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    Ptr Word8 ->                            -- data : TCArray False (-1) 2 (TBasicType TUInt8)
    Word64 ->                               -- length : TBasicType TUInt64
    IO ()

{- |
Send a binary message to the peer.

The message is queued to be sent and will be sent when the main loop
is run.

@since 2.50
-}
websocketConnectionSendBinary ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> ByteString
    {- ^ /@data@/: the message contents -}
    -> m ()
websocketConnectionSendBinary self data_ = liftIO $ do
    let length_ = fromIntegral $ B.length data_
    self' <- unsafeManagedPtrCastPtr self
    data_' <- packByteString data_
    soup_websocket_connection_send_binary self' data_' length_
    touchManagedPtr self
    freeMem data_'
    return ()

data WebsocketConnectionSendBinaryMethodInfo
instance (signature ~ (ByteString -> m ()), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionSendBinaryMethodInfo a signature where
    overloadedMethod _ = websocketConnectionSendBinary

-- method WebsocketConnection::send_text
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the message contents", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_send_text" soup_websocket_connection_send_text :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    CString ->                              -- text : TBasicType TUTF8
    IO ()

{- |
Send a text (UTF-8) message to the peer.

The message is queued to be sent and will be sent when the main loop
is run.

@since 2.50
-}
websocketConnectionSendText ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> T.Text
    {- ^ /@text@/: the message contents -}
    -> m ()
websocketConnectionSendText self text = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    text' <- textToCString text
    soup_websocket_connection_send_text self' text'
    touchManagedPtr self
    freeMem text'
    return ()

data WebsocketConnectionSendTextMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionSendTextMethodInfo a signature where
    overloadedMethod _ = websocketConnectionSendText

-- method WebsocketConnection::set_max_incoming_payload_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "self", argType = TInterface (Name {namespace = "Soup", name = "WebsocketConnection"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the WebSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "max_incoming_payload_size", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the maximum payload size", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_connection_set_max_incoming_payload_size" soup_websocket_connection_set_max_incoming_payload_size :: 
    Ptr WebsocketConnection ->              -- self : TInterface (Name {namespace = "Soup", name = "WebsocketConnection"})
    Word64 ->                               -- max_incoming_payload_size : TBasicType TUInt64
    IO ()

{- |
Sets the maximum payload size allowed for incoming packets. It
does not limit the outgoing packet size.

@since 2.56
-}
websocketConnectionSetMaxIncomingPayloadSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebsocketConnection a) =>
    a
    {- ^ /@self@/: the WebSocket -}
    -> Word64
    {- ^ /@maxIncomingPayloadSize@/: the maximum payload size -}
    -> m ()
websocketConnectionSetMaxIncomingPayloadSize self maxIncomingPayloadSize = liftIO $ do
    self' <- unsafeManagedPtrCastPtr self
    soup_websocket_connection_set_max_incoming_payload_size self' maxIncomingPayloadSize
    touchManagedPtr self
    return ()

data WebsocketConnectionSetMaxIncomingPayloadSizeMethodInfo
instance (signature ~ (Word64 -> m ()), MonadIO m, IsWebsocketConnection a) => O.MethodInfo WebsocketConnectionSetMaxIncomingPayloadSizeMethodInfo a signature where
    overloadedMethod _ = websocketConnectionSetMaxIncomingPayloadSize