| 1 |
/* |
| 2 |
* Copyright (C) 2013 Red Hat, Inc. |
| 3 |
* SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
*/ |
| 5 |
|
| 6 |
#pragma once |
| 7 |
|
| 8 |
#include "websocket.h" |
| 9 |
|
| 10 |
#include <gio/gio.h> |
| 11 |
|
| 12 |
G_BEGIN_DECLS |
| 13 |
|
| 14 |
#define WEB_SOCKET_TYPE_CONNECTION (web_socket_connection_get_type ()) |
| 15 |
G_DECLARE_DERIVABLE_TYPE(WebSocketConnection, web_socket_connection, WEB_SOCKET, CONNECTION, GObject) |
| 16 |
|
| 17 |
struct _WebSocketConnectionClass |
| 18 |
{ |
| 19 |
GObjectClass parent; |
| 20 |
|
| 21 |
/* set by derived */ |
| 22 |
gboolean server_behavior; |
| 23 |
|
| 24 |
/* vfuncs */ |
| 25 |
gboolean (* handshake) (WebSocketConnection *self, |
| 26 |
GByteArray *incoming); |
| 27 |
|
| 28 |
/* signals */ |
| 29 |
void (* open) (WebSocketConnection *self); |
| 30 |
|
| 31 |
void (* message) (WebSocketConnection *self, |
| 32 |
WebSocketDataType type, |
| 33 |
GBytes *message); |
| 34 |
|
| 35 |
gboolean (* error) (WebSocketConnection *self, |
| 36 |
GError *error); |
| 37 |
|
| 38 |
gboolean (* closing) (WebSocketConnection *self); |
| 39 |
|
| 40 |
void (* close) (WebSocketConnection *self); |
| 41 |
}; |
| 42 |
|
| 43 |
GType web_socket_connection_get_type (void) G_GNUC_CONST; |
| 44 |
|
| 45 |
const gchar * web_socket_connection_get_url (WebSocketConnection *self); |
| 46 |
|
| 47 |
const gchar * web_socket_connection_get_protocol (WebSocketConnection *self); |
| 48 |
|
| 49 |
WebSocketState web_socket_connection_get_ready_state (WebSocketConnection *self); |
| 50 |
|
| 51 |
gsize web_socket_connection_get_buffered_amount (WebSocketConnection *self); |
| 52 |
|
| 53 |
gushort web_socket_connection_get_close_code (WebSocketConnection *self); |
| 54 |
|
| 55 |
const gchar * web_socket_connection_get_close_data (WebSocketConnection *self); |
| 56 |
|
| 57 |
GIOStream * web_socket_connection_get_io_stream (WebSocketConnection *self); |
| 58 |
|
| 59 |
void web_socket_connection_send (WebSocketConnection *self, |
| 60 |
WebSocketDataType type, |
| 61 |
GBytes *prefix, |
| 62 |
GBytes *payload); |
| 63 |
|
| 64 |
void web_socket_connection_close (WebSocketConnection *self, |
| 65 |
gushort code, |
| 66 |
const gchar *data); |