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
27G_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
36typedef struct _SoupWebsocketConnectionPrivate SoupWebsocketConnectionPrivate;
37
38struct _SoupWebsocketConnection {
39 GObject parent;
40
41 /*< private >*/
42 SoupWebsocketConnectionPrivate *pv;
43};
44
45typedef 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
64SOUP_AVAILABLE_IN_2_50
65GType soup_websocket_connection_get_type (void) G_GNUC_CONST;
66
67SOUP_AVAILABLE_IN_2_50
68SoupWebsocketConnection *soup_websocket_connection_new (GIOStream *stream,
69 SoupURI *uri,
70 SoupWebsocketConnectionType type,
71 const char *origin,
72 const char *protocol);
73
74SOUP_AVAILABLE_IN_2_50
75GIOStream * soup_websocket_connection_get_io_stream (SoupWebsocketConnection *self);
76
77SOUP_AVAILABLE_IN_2_50
78SoupWebsocketConnectionType soup_websocket_connection_get_connection_type (SoupWebsocketConnection *self);
79
80SOUP_AVAILABLE_IN_2_50
81SoupURI * soup_websocket_connection_get_uri (SoupWebsocketConnection *self);
82
83SOUP_AVAILABLE_IN_2_50
84const char * soup_websocket_connection_get_origin (SoupWebsocketConnection *self);
85
86SOUP_AVAILABLE_IN_2_50
87const char * soup_websocket_connection_get_protocol (SoupWebsocketConnection *self);
88
89SOUP_AVAILABLE_IN_2_50
90SoupWebsocketState soup_websocket_connection_get_state (SoupWebsocketConnection *self);
91
92SOUP_AVAILABLE_IN_2_50
93gushort soup_websocket_connection_get_close_code (SoupWebsocketConnection *self);
94
95SOUP_AVAILABLE_IN_2_50
96const char * soup_websocket_connection_get_close_data (SoupWebsocketConnection *self);
97
98SOUP_AVAILABLE_IN_2_50
99void soup_websocket_connection_send_text (SoupWebsocketConnection *self,
100 const char *text);
101SOUP_AVAILABLE_IN_2_50
102void soup_websocket_connection_send_binary (SoupWebsocketConnection *self,
103 gconstpointer data,
104 gsize length);
105
106SOUP_AVAILABLE_IN_2_50
107void soup_websocket_connection_close (SoupWebsocketConnection *self,
108 gushort code,
109 const char *data);
110
111SOUP_AVAILABLE_IN_2_56
112guint64 soup_websocket_connection_get_max_incoming_payload_size (SoupWebsocketConnection *self);
113
114SOUP_AVAILABLE_IN_2_56
115void soup_websocket_connection_set_max_incoming_payload_size (SoupWebsocketConnection *self,
116 guint64 max_incoming_payload_size);
117
118SOUP_AVAILABLE_IN_2_58
119guint soup_websocket_connection_get_keepalive_interval (SoupWebsocketConnection *self);
120
121SOUP_AVAILABLE_IN_2_58
122void soup_websocket_connection_set_keepalive_interval (SoupWebsocketConnection *self,
123 guint interval);
124
125G_END_DECLS
126
127#endif /* __SOUP_WEBSOCKET_CONNECTION_H__ */
128