soup-websocket-connection.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
  2. /*
  3. * soup-websocket-connection.h: This file was originally part of Cockpit.
  4. *
  5. * Copyright 2013, 2014 Red Hat, Inc.
  6. *
  7. * Cockpit is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU Lesser General Public License as published by
  9. * the Free Software Foundation; either version 2.1 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Cockpit is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public License
  18. * along with this library; If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef __SOUP_WEBSOCKET_CONNECTION_H__
  21. #define __SOUP_WEBSOCKET_CONNECTION_H__
  22. #include <libsoup/soup-types.h>
  23. #include <libsoup/soup-websocket.h>
  24. G_BEGIN_DECLS
  25. #define SOUP_TYPE_WEBSOCKET_CONNECTION (soup_websocket_connection_get_type ())
  26. #define SOUP_WEBSOCKET_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SOUP_TYPE_WEBSOCKET_CONNECTION, SoupWebsocketConnection))
  27. #define SOUP_IS_WEBSOCKET_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SOUP_TYPE_WEBSOCKET_CONNECTION))
  28. #define SOUP_WEBSOCKET_CONNECTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SOUP_TYPE_WEBSOCKET_CONNECTION, SoupWebsocketConnectionClass))
  29. #define SOUP_WEBSOCKET_CONNECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), SOUP_TYPE_WEBSOCKET_CONNECTION, SoupWebsocketConnectionClass))
  30. #define SOUP_IS_WEBSOCKET_CONNECTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SOUP_TYPE_WEBSOCKET_CONNECTION))
  31. typedef struct _SoupWebsocketConnectionPrivate SoupWebsocketConnectionPrivate;
  32. struct _SoupWebsocketConnection {
  33. GObject parent;
  34. /*< private >*/
  35. SoupWebsocketConnectionPrivate *pv;
  36. };
  37. typedef struct {
  38. GObjectClass parent;
  39. /* signals */
  40. void (* message) (SoupWebsocketConnection *self,
  41. SoupWebsocketDataType type,
  42. GBytes *message);
  43. void (* error) (SoupWebsocketConnection *self,
  44. GError *error);
  45. void (* closing) (SoupWebsocketConnection *self);
  46. void (* closed) (SoupWebsocketConnection *self);
  47. void (* pong) (SoupWebsocketConnection *self,
  48. GBytes *message);
  49. } SoupWebsocketConnectionClass;
  50. SOUP_AVAILABLE_IN_2_50
  51. GType soup_websocket_connection_get_type (void) G_GNUC_CONST;
  52. SOUP_AVAILABLE_IN_2_50
  53. SoupWebsocketConnection *soup_websocket_connection_new (GIOStream *stream,
  54. SoupURI *uri,
  55. SoupWebsocketConnectionType type,
  56. const char *origin,
  57. const char *protocol);
  58. SOUP_AVAILABLE_IN_2_68
  59. SoupWebsocketConnection *soup_websocket_connection_new_with_extensions (GIOStream *stream,
  60. SoupURI *uri,
  61. SoupWebsocketConnectionType type,
  62. const char *origin,
  63. const char *protocol,
  64. GList *extensions);
  65. SOUP_AVAILABLE_IN_2_50
  66. GIOStream * soup_websocket_connection_get_io_stream (SoupWebsocketConnection *self);
  67. SOUP_AVAILABLE_IN_2_50
  68. SoupWebsocketConnectionType soup_websocket_connection_get_connection_type (SoupWebsocketConnection *self);
  69. SOUP_AVAILABLE_IN_2_50
  70. SoupURI * soup_websocket_connection_get_uri (SoupWebsocketConnection *self);
  71. SOUP_AVAILABLE_IN_2_50
  72. const char * soup_websocket_connection_get_origin (SoupWebsocketConnection *self);
  73. SOUP_AVAILABLE_IN_2_50
  74. const char * soup_websocket_connection_get_protocol (SoupWebsocketConnection *self);
  75. SOUP_AVAILABLE_IN_2_68
  76. GList * soup_websocket_connection_get_extensions (SoupWebsocketConnection *self);
  77. SOUP_AVAILABLE_IN_2_50
  78. SoupWebsocketState soup_websocket_connection_get_state (SoupWebsocketConnection *self);
  79. SOUP_AVAILABLE_IN_2_50
  80. gushort soup_websocket_connection_get_close_code (SoupWebsocketConnection *self);
  81. SOUP_AVAILABLE_IN_2_50
  82. const char * soup_websocket_connection_get_close_data (SoupWebsocketConnection *self);
  83. SOUP_AVAILABLE_IN_2_50
  84. void soup_websocket_connection_send_text (SoupWebsocketConnection *self,
  85. const char *text);
  86. SOUP_AVAILABLE_IN_2_50
  87. void soup_websocket_connection_send_binary (SoupWebsocketConnection *self,
  88. gconstpointer data,
  89. gsize length);
  90. SOUP_AVAILABLE_IN_2_68
  91. void soup_websocket_connection_send_message (SoupWebsocketConnection *self,
  92. SoupWebsocketDataType type,
  93. GBytes *message);
  94. SOUP_AVAILABLE_IN_2_50
  95. void soup_websocket_connection_close (SoupWebsocketConnection *self,
  96. gushort code,
  97. const char *data);
  98. SOUP_AVAILABLE_IN_2_56
  99. guint64 soup_websocket_connection_get_max_incoming_payload_size (SoupWebsocketConnection *self);
  100. SOUP_AVAILABLE_IN_2_56
  101. void soup_websocket_connection_set_max_incoming_payload_size (SoupWebsocketConnection *self,
  102. guint64 max_incoming_payload_size);
  103. SOUP_AVAILABLE_IN_2_58
  104. guint soup_websocket_connection_get_keepalive_interval (SoupWebsocketConnection *self);
  105. SOUP_AVAILABLE_IN_2_58
  106. void soup_websocket_connection_set_keepalive_interval (SoupWebsocketConnection *self,
  107. guint interval);
  108. G_END_DECLS
  109. #endif /* __SOUP_WEBSOCKET_CONNECTION_H__ */