// GENERATED — DO NOT EDIT

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/class.WebsocketConnection.html).
pub type WebsocketConnection

///|
pub(open) trait IWebsocketConnection {
  fn as_websocket_connection(Self) -> WebsocketConnection
  fn close(Self, UInt, String?) -> Unit = _
  fn get_close_code(Self) -> UInt = _
  fn get_close_data(Self) -> String = _
  fn get_connection_type(Self) -> WebsocketConnectionType = _
  fn get_io_stream(Self) -> @gio.IOStream = _
  fn get_keepalive_interval(Self) -> UInt = _
  fn get_keepalive_pong_timeout(Self) -> UInt = _
  fn get_max_incoming_payload_size(Self) -> UInt64 = _
  fn get_origin(Self) -> String? = _
  fn get_protocol(Self) -> String? = _
  fn get_state(Self) -> WebsocketState = _
  fn get_uri(Self) -> @glib.Uri = _
  fn send_message(Self, WebsocketDataType, Bytes) -> Unit = _
  fn send_text(Self, String) -> Unit = _
  fn set_keepalive_interval(Self, UInt) -> Unit = _
  fn set_keepalive_pong_timeout(Self, UInt) -> Unit = _
  fn set_max_incoming_payload_size(Self, UInt64) -> Unit = _
  fn connect_closed(Self, (WebsocketConnection) -> Unit) -> UInt64 = _
  fn connect_closing(Self, (WebsocketConnection) -> Unit) -> UInt64 = _
  fn connect_message(Self, (WebsocketConnection, Int, Bytes) -> Unit) -> UInt64 = _
  fn connect_pong(Self, (WebsocketConnection, Bytes) -> Unit) -> UInt64 = _
}

///|
pub impl IWebsocketConnection for WebsocketConnection with fn as_websocket_connection(
  self,
) {
  self
}

///|
#borrow(self_, data)
extern "c" fn moonbit_soup_websocket_connection_close(
  self_ : WebsocketConnection,
  code : UInt,
  data : @glib.Nullable[Bytes],
) = "moonbit_soup_websocket_connection_close"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.close.html).
pub fn WebsocketConnection::close(
  self : WebsocketConnection,
  code : UInt,
  data : String?,
) -> Unit {
  moonbit_soup_websocket_connection_close(
    self,
    code,
    match data {
      Some(s) => @glib.Nullable::some(@encoding/utf8.encode(s))
      None => @glib.Nullable::null()
    },
  )
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_close_code.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::get_close_code(
  self : WebsocketConnection,
) -> UInt = "moonbit_soup_websocket_connection_get_close_code"

///|
#borrow(self_)
extern "c" fn moonbit_soup_websocket_connection_get_close_data(
  self_ : WebsocketConnection,
) -> Bytes = "moonbit_soup_websocket_connection_get_close_data"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_close_data.html).
pub fn WebsocketConnection::get_close_data(
  self : WebsocketConnection,
) -> String {
  @encoding/utf8.decode_lossy(
    moonbit_soup_websocket_connection_get_close_data(self),
  )
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_connection_type.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::get_connection_type(
  self : WebsocketConnection,
) -> WebsocketConnectionType = "moonbit_soup_websocket_connection_get_connection_type"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_io_stream.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::get_io_stream(
  self : WebsocketConnection,
) -> @gio.IOStream = "moonbit_soup_websocket_connection_get_io_stream"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_keepalive_interval.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::get_keepalive_interval(
  self : WebsocketConnection,
) -> UInt = "moonbit_soup_websocket_connection_get_keepalive_interval"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_keepalive_pong_timeout.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::get_keepalive_pong_timeout(
  self : WebsocketConnection,
) -> UInt = "moonbit_soup_websocket_connection_get_keepalive_pong_timeout"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_max_incoming_payload_size.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::get_max_incoming_payload_size(
  self : WebsocketConnection,
) -> UInt64 = "moonbit_soup_websocket_connection_get_max_incoming_payload_size"

///|
#borrow(self_)
extern "c" fn moonbit_soup_websocket_connection_get_origin(
  self_ : WebsocketConnection,
) -> @glib.Nullable[Bytes] = "moonbit_soup_websocket_connection_get_origin"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_origin.html).
pub fn WebsocketConnection::get_origin(self : WebsocketConnection) -> String? {
  let result = moonbit_soup_websocket_connection_get_origin(self)
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
#borrow(self_)
extern "c" fn moonbit_soup_websocket_connection_get_protocol(
  self_ : WebsocketConnection,
) -> @glib.Nullable[Bytes] = "moonbit_soup_websocket_connection_get_protocol"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_protocol.html).
pub fn WebsocketConnection::get_protocol(self : WebsocketConnection) -> String? {
  let result = moonbit_soup_websocket_connection_get_protocol(self)
  match result.to_option() {
    Some(bytes) => Some(@encoding/utf8.decode_lossy(bytes))
    None => None
  }
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_state.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::get_state(
  self : WebsocketConnection,
) -> WebsocketState = "moonbit_soup_websocket_connection_get_state"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.get_uri.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::get_uri(
  self : WebsocketConnection,
) -> @glib.Uri = "moonbit_soup_websocket_connection_get_uri"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.send_message.html).
#borrow(self, message)
pub extern "c" fn WebsocketConnection::send_message(
  self : WebsocketConnection,
  type_ : WebsocketDataType,
  message : Bytes,
) = "moonbit_soup_websocket_connection_send_message"

///|
#borrow(self_, text)
extern "c" fn moonbit_soup_websocket_connection_send_text(
  self_ : WebsocketConnection,
  text : Bytes,
) = "moonbit_soup_websocket_connection_send_text"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.send_text.html).
pub fn WebsocketConnection::send_text(
  self : WebsocketConnection,
  text : String,
) -> Unit {
  moonbit_soup_websocket_connection_send_text(self, @encoding/utf8.encode(text))
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.set_keepalive_interval.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::set_keepalive_interval(
  self : WebsocketConnection,
  interval : UInt,
) = "moonbit_soup_websocket_connection_set_keepalive_interval"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.set_keepalive_pong_timeout.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::set_keepalive_pong_timeout(
  self : WebsocketConnection,
  pong_timeout : UInt,
) = "moonbit_soup_websocket_connection_set_keepalive_pong_timeout"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/method.WebsocketConnection.set_max_incoming_payload_size.html).
#borrow(self)
pub extern "c" fn WebsocketConnection::set_max_incoming_payload_size(
  self : WebsocketConnection,
  max_incoming_payload_size : UInt64,
) = "moonbit_soup_websocket_connection_set_max_incoming_payload_size"

///|
/// Creates a new WebsocketConnection with default property values.
pub extern "c" fn WebsocketConnection::new() -> WebsocketConnection = "moonbit_soup_websocket_connection_new"

///|
#borrow(instance)
extern "c" fn soup_websocket_connection_connect_closed(
  instance : WebsocketConnection,
  function : FuncRef[
    (WebsocketConnection, (WebsocketConnection) -> Unit) -> Unit,
  ],
  closure : (WebsocketConnection) -> Unit,
) -> UInt64 = "moonbit_soup_websocket_connection_connect_closed"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/signal.WebsocketConnection.closed.html).
pub fn WebsocketConnection::connect_closed(
  self : WebsocketConnection,
  f : (WebsocketConnection) -> Unit,
) -> UInt64 {
  soup_websocket_connection_connect_closed(
    self,
    fn(instance_, f) { f(instance_) },
    f,
  )
}

///|
#borrow(instance)
extern "c" fn soup_websocket_connection_connect_closing(
  instance : WebsocketConnection,
  function : FuncRef[
    (WebsocketConnection, (WebsocketConnection) -> Unit) -> Unit,
  ],
  closure : (WebsocketConnection) -> Unit,
) -> UInt64 = "moonbit_soup_websocket_connection_connect_closing"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/signal.WebsocketConnection.closing.html).
pub fn WebsocketConnection::connect_closing(
  self : WebsocketConnection,
  f : (WebsocketConnection) -> Unit,
) -> UInt64 {
  soup_websocket_connection_connect_closing(
    self,
    fn(instance_, f) { f(instance_) },
    f,
  )
}

///|
#borrow(instance)
extern "c" fn soup_websocket_connection_connect_message(
  instance : WebsocketConnection,
  function : FuncRef[
    (WebsocketConnection, Int, Bytes, (WebsocketConnection, Int, Bytes) -> Unit) -> Unit,
  ],
  closure : (WebsocketConnection, Int, Bytes) -> Unit,
) -> UInt64 = "moonbit_soup_websocket_connection_connect_message"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/signal.WebsocketConnection.message.html).
pub fn WebsocketConnection::connect_message(
  self : WebsocketConnection,
  f : (WebsocketConnection, Int, Bytes) -> Unit,
) -> UInt64 {
  soup_websocket_connection_connect_message(
    self,
    fn(instance_, type_, message, f) { f(instance_, type_, message) },
    f,
  )
}

///|
#borrow(instance)
extern "c" fn soup_websocket_connection_connect_pong(
  instance : WebsocketConnection,
  function : FuncRef[
    (WebsocketConnection, Bytes, (WebsocketConnection, Bytes) -> Unit) -> Unit,
  ],
  closure : (WebsocketConnection, Bytes) -> Unit,
) -> UInt64 = "moonbit_soup_websocket_connection_connect_pong"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/libsoup/libsoup-3.0/signal.WebsocketConnection.pong.html).
pub fn WebsocketConnection::connect_pong(
  self : WebsocketConnection,
  f : (WebsocketConnection, Bytes) -> Unit,
) -> UInt64 {
  soup_websocket_connection_connect_pong(
    self,
    fn(instance_, message, f) { f(instance_, message) },
    f,
  )
}

///|
impl IWebsocketConnection with fn close(self, code, data) -> Unit {
  self.as_websocket_connection().close(code, data)
}

///|
impl IWebsocketConnection with fn get_close_code(self) -> UInt {
  self.as_websocket_connection().get_close_code()
}

///|
impl IWebsocketConnection with fn get_close_data(self) -> String {
  self.as_websocket_connection().get_close_data()
}

///|
impl IWebsocketConnection with fn get_connection_type(self) -> WebsocketConnectionType {
  self.as_websocket_connection().get_connection_type()
}

///|
impl IWebsocketConnection with fn get_io_stream(self) -> @gio.IOStream {
  self.as_websocket_connection().get_io_stream()
}

///|
impl IWebsocketConnection with fn get_keepalive_interval(self) -> UInt {
  self.as_websocket_connection().get_keepalive_interval()
}

///|
impl IWebsocketConnection with fn get_keepalive_pong_timeout(self) -> UInt {
  self.as_websocket_connection().get_keepalive_pong_timeout()
}

///|
impl IWebsocketConnection with fn get_max_incoming_payload_size(self) -> UInt64 {
  self.as_websocket_connection().get_max_incoming_payload_size()
}

///|
impl IWebsocketConnection with fn get_origin(self) -> String? {
  self.as_websocket_connection().get_origin()
}

///|
impl IWebsocketConnection with fn get_protocol(self) -> String? {
  self.as_websocket_connection().get_protocol()
}

///|
impl IWebsocketConnection with fn get_state(self) -> WebsocketState {
  self.as_websocket_connection().get_state()
}

///|
impl IWebsocketConnection with fn get_uri(self) -> @glib.Uri {
  self.as_websocket_connection().get_uri()
}

///|
impl IWebsocketConnection with fn send_message(self, type_, message) -> Unit {
  self.as_websocket_connection().send_message(type_, message)
}

///|
impl IWebsocketConnection with fn send_text(self, text) -> Unit {
  self.as_websocket_connection().send_text(text)
}

///|
impl IWebsocketConnection with fn set_keepalive_interval(self, interval) -> Unit {
  self.as_websocket_connection().set_keepalive_interval(interval)
}

///|
impl IWebsocketConnection with fn set_keepalive_pong_timeout(self, pong_timeout) -> Unit {
  self.as_websocket_connection().set_keepalive_pong_timeout(pong_timeout)
}

///|
impl IWebsocketConnection with fn set_max_incoming_payload_size(
  self,
  max_incoming_payload_size,
) -> Unit {
  self
  .as_websocket_connection()
  .set_max_incoming_payload_size(max_incoming_payload_size)
}

///|
impl IWebsocketConnection with fn connect_closed(self, f) -> UInt64 {
  self.as_websocket_connection().connect_closed(f)
}

///|
impl IWebsocketConnection with fn connect_closing(self, f) -> UInt64 {
  self.as_websocket_connection().connect_closing(f)
}

///|
impl IWebsocketConnection with fn connect_message(self, f) -> UInt64 {
  self.as_websocket_connection().connect_message(f)
}

///|
impl IWebsocketConnection with fn connect_pong(self, f) -> UInt64 {
  self.as_websocket_connection().connect_pong(f)
}

///|
pub fn WebsocketConnection::as_gobject_object(
  self : WebsocketConnection,
) -> @gobject.Object = "%identity"

///|
pub impl @gobject.IObject for WebsocketConnection with fn as_object(self) {
  self.as_gobject_object()
}