| 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 | |
| 74 | SOUP_AVAILABLE_IN_2_50 |
| 75 | GIOStream * soup_websocket_connection_get_io_stream (SoupWebsocketConnection *self); |
| 76 | |
| 77 | SOUP_AVAILABLE_IN_2_50 |
| 78 | SoupWebsocketConnectionType soup_websocket_connection_get_connection_type (SoupWebsocketConnection *self); |
| 79 | |
| 80 | SOUP_AVAILABLE_IN_2_50 |
| 81 | SoupURI * soup_websocket_connection_get_uri (SoupWebsocketConnection *self); |
| 82 | |
| 83 | SOUP_AVAILABLE_IN_2_50 |
| 84 | const char * soup_websocket_connection_get_origin (SoupWebsocketConnection *self); |
| 85 | |
| 86 | SOUP_AVAILABLE_IN_2_50 |
| 87 | const char * soup_websocket_connection_get_protocol (SoupWebsocketConnection *self); |
| 88 | |
| 89 | SOUP_AVAILABLE_IN_2_50 |
| 90 | SoupWebsocketState soup_websocket_connection_get_state (SoupWebsocketConnection *self); |
| 91 | |
| 92 | SOUP_AVAILABLE_IN_2_50 |
| 93 | gushort soup_websocket_connection_get_close_code (SoupWebsocketConnection *self); |
| 94 | |
| 95 | SOUP_AVAILABLE_IN_2_50 |
| 96 | const char * soup_websocket_connection_get_close_data (SoupWebsocketConnection *self); |
| 97 | |
| 98 | SOUP_AVAILABLE_IN_2_50 |
| 99 | void soup_websocket_connection_send_text (SoupWebsocketConnection *self, |
| 100 | const char *text); |
| 101 | SOUP_AVAILABLE_IN_2_50 |
| 102 | void soup_websocket_connection_send_binary (SoupWebsocketConnection *self, |
| 103 | gconstpointer data, |
| 104 | gsize length); |
| 105 | |
| 106 | SOUP_AVAILABLE_IN_2_50 |
| 107 | void soup_websocket_connection_close (SoupWebsocketConnection *self, |
| 108 | gushort code, |
| 109 | const char *data); |
| 110 | |
| 111 | SOUP_AVAILABLE_IN_2_56 |
| 112 | guint64 soup_websocket_connection_get_max_incoming_payload_size (SoupWebsocketConnection *self); |
| 113 | |
| 114 | SOUP_AVAILABLE_IN_2_56 |
| 115 | void soup_websocket_connection_set_max_incoming_payload_size (SoupWebsocketConnection *self, |
| 116 | guint64 max_incoming_payload_size); |
| 117 | |
| 118 | SOUP_AVAILABLE_IN_2_58 |
| 119 | guint soup_websocket_connection_get_keepalive_interval (SoupWebsocketConnection *self); |
| 120 | |
| 121 | SOUP_AVAILABLE_IN_2_58 |
| 122 | void soup_websocket_connection_set_keepalive_interval (SoupWebsocketConnection *self, |
| 123 | guint interval); |
| 124 | |
| 125 | G_END_DECLS |
| 126 | |
| 127 | #endif /* __SOUP_WEBSOCKET_CONNECTION_H__ */ |
| 128 | |