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 21 #ifndef __SOUP_WEBSOCKET_CONNECTION_H__ 22 #define __SOUP_WEBSOCKET_CONNECTION_H__ 23 24 #include <libsoup/soup-types.h> 25 #include <libsoup/soup-websocket.h> 26 27 G_BEGIN_DECLS 28 29 #define SOUP_TYPE_WEBSOCKET_CONNECTION (soup_websocket_connection_get_type ()) 30 #define SOUP_WEBSOCKET_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SOUP_TYPE_WEBSOCKET_CONNECTION, SoupWebsocketConnection)) 31 #define SOUP_IS_WEBSOCKET_CONNECTION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SOUP_TYPE_WEBSOCKET_CONNECTION)) 32 #define SOUP_WEBSOCKET_CONNECTION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SOUP_TYPE_WEBSOCKET_CONNECTION, SoupWebsocketConnectionClass)) 33 #define SOUP_WEBSOCKET_CONNECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), SOUP_TYPE_WEBSOCKET_CONNECTION, SoupWebsocketConnectionClass)) 34 #define SOUP_IS_WEBSOCKET_CONNECTION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SOUP_TYPE_WEBSOCKET_CONNECTION)) 35 36 typedef struct _SoupWebsocketConnectionPrivate SoupWebsocketConnectionPrivate; 37 38 struct _SoupWebsocketConnection { 39 GObject parent; 40 41 /*< private >*/ 42 SoupWebsocketConnectionPrivate *pv; 43 }; 44 45 typedef struct { 46 GObjectClass parent; 47 48 /* signals */ 49 void (* message) (SoupWebsocketConnection *self, 50 SoupWebsocketDataType type, 51 GBytes *message); 52 53 void (* error) (SoupWebsocketConnection *self, 54 GError *error); 55 56 void (* closing) (SoupWebsocketConnection *self); 57 58 void (* closed) (SoupWebsocketConnection *self); 59 60 void (* pong) (SoupWebsocketConnection *self, 61 GBytes *message); 62 } SoupWebsocketConnectionClass; 63 64 SOUP_AVAILABLE_IN_2_50 65 GType soup_websocket_connection_get_type (void) G_GNUC_CONST; 66 67 SOUP_AVAILABLE_IN_2_50 68 SoupWebsocketConnection *soup_websocket_connection_new (GIOStream *stream, 69 SoupURI *uri, 70 SoupWebsocketConnectionType type, 71 const char *origin, 72 const char *protocol); 73 SOUP_AVAILABLE_IN_2_68 74 SoupWebsocketConnection *soup_websocket_connection_new_with_extensions (GIOStream *stream, 75 SoupURI *uri, 76 SoupWebsocketConnectionType type, 77 const char *origin, 78 const char *protocol, 79 GList *extensions); 80 81 SOUP_AVAILABLE_IN_2_50 82 GIOStream * soup_websocket_connection_get_io_stream (SoupWebsocketConnection *self); 83 84 SOUP_AVAILABLE_IN_2_50 85 SoupWebsocketConnectionType soup_websocket_connection_get_connection_type (SoupWebsocketConnection *self); 86 87 SOUP_AVAILABLE_IN_2_50 88 SoupURI * soup_websocket_connection_get_uri (SoupWebsocketConnection *self); 89 90 SOUP_AVAILABLE_IN_2_50 91 const char * soup_websocket_connection_get_origin (SoupWebsocketConnection *self); 92 93 SOUP_AVAILABLE_IN_2_50 94 const char * soup_websocket_connection_get_protocol (SoupWebsocketConnection *self); 95 96 SOUP_AVAILABLE_IN_2_68 97 GList * soup_websocket_connection_get_extensions (SoupWebsocketConnection *self); 98 99 SOUP_AVAILABLE_IN_2_50 100 SoupWebsocketState soup_websocket_connection_get_state (SoupWebsocketConnection *self); 101 102 SOUP_AVAILABLE_IN_2_50 103 gushort soup_websocket_connection_get_close_code (SoupWebsocketConnection *self); 104 105 SOUP_AVAILABLE_IN_2_50 106 const char * soup_websocket_connection_get_close_data (SoupWebsocketConnection *self); 107 108 SOUP_AVAILABLE_IN_2_50 109 void soup_websocket_connection_send_text (SoupWebsocketConnection *self, 110 const char *text); 111 SOUP_AVAILABLE_IN_2_50 112 void soup_websocket_connection_send_binary (SoupWebsocketConnection *self, 113 gconstpointer data, 114 gsize length); 115 SOUP_AVAILABLE_IN_2_68 116 void soup_websocket_connection_send_message (SoupWebsocketConnection *self, 117 SoupWebsocketDataType type, 118 GBytes *message); 119 120 SOUP_AVAILABLE_IN_2_50 121 void soup_websocket_connection_close (SoupWebsocketConnection *self, 122 gushort code, 123 const char *data); 124 125 SOUP_AVAILABLE_IN_2_56 126 guint64 soup_websocket_connection_get_max_incoming_payload_size (SoupWebsocketConnection *self); 127 128 SOUP_AVAILABLE_IN_2_56 129 void soup_websocket_connection_set_max_incoming_payload_size (SoupWebsocketConnection *self, 130 guint64 max_incoming_payload_size); 131 132 SOUP_AVAILABLE_IN_2_58 133 guint soup_websocket_connection_get_keepalive_interval (SoupWebsocketConnection *self); 134 135 SOUP_AVAILABLE_IN_2_58 136 void soup_websocket_connection_set_keepalive_interval (SoupWebsocketConnection *self, 137 guint interval); 138 139 G_END_DECLS 140 141 #endif /* __SOUP_WEBSOCKET_CONNECTION_H__ */ 142