[libsoup/carlosgc/server-http2: 7/13] soup-server-message: add connected signal
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/carlosgc/server-http2: 7/13] soup-server-message: add connected signal
- Date: Mon, 1 Aug 2022 10:08:23 +0000 (UTC)
commit 1b428e783c69f33efe341814cb6cfbe390b40ed6
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Tue Jul 19 10:22:06 2022 +0200
soup-server-message: add connected signal
Emitted when the connection is connected and the TLS handshake
completed. Use connection connected signal to set the IO data.
libsoup/server/soup-server-connection.c | 14 +++++++++++++-
libsoup/server/soup-server-message.c | 28 +++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/server/soup-server-connection.c b/libsoup/server/soup-server-connection.c
index d84bd8d5..4880a324 100644
--- a/libsoup/server/soup-server-connection.c
+++ b/libsoup/server/soup-server-connection.c
@@ -22,6 +22,7 @@
#include "soup-server-message-io-http1.h"
enum {
+ CONNECTED,
DISCONNECTED,
ACCEPT_CERTIFICATE,
LAST_SIGNAL
@@ -201,6 +202,15 @@ soup_server_connection_class_init (SoupServerConnectionClass *conn_class)
object_class->set_property = soup_server_connection_set_property;
object_class->get_property = soup_server_connection_get_property;
+ signals[CONNECTED] =
+ g_signal_new ("connected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE, 0);
+
/**
* SoupServerConnection::disconnected:
* @conn: the connection
@@ -469,8 +479,10 @@ soup_server_connection_setup_finish (SoupServerConnection *conn,
{
GTask *task = G_TASK (result);
- if (!g_task_had_error (task))
+ if (!g_task_had_error (task)) {
soup_server_connection_create_io_data (conn);
+ g_signal_emit (conn, signals[CONNECTED], 0);
+ }
return g_task_propagate_boolean (task, error);
}
diff --git a/libsoup/server/soup-server-message.c b/libsoup/server/soup-server-message.c
index d81d4722..5df59853 100644
--- a/libsoup/server/soup-server-message.c
+++ b/libsoup/server/soup-server-message.c
@@ -83,6 +83,7 @@ enum {
GOT_CHUNK,
GOT_BODY,
+ CONNECTED,
DISCONNECTED,
FINISHED,
@@ -318,6 +319,20 @@ soup_server_message_class_init (SoupServerMessageClass *klass)
NULL, NULL,
NULL,
G_TYPE_NONE, 0);
+ /**
+ * SoupServerMessage::connected:
+ * @msg: the message
+ *
+ * Emitted when the @msg's socket is connected and the TLS handshake completed.
+ */
+ signals[CONNECTED] =
+ g_signal_new ("connected",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE, 0);
/**
* SoupServerMessage::disconnected:
@@ -393,6 +408,14 @@ soup_server_message_class_init (SoupServerMessageClass *klass)
g_object_class_install_properties (object_class, LAST_PROPERTY, properties);
}
+static void
+connection_connected (SoupServerMessage *msg)
+{
+ g_assert (!msg->io_data);
+ msg->io_data = soup_server_connection_get_io_data (msg->conn);
+ g_signal_emit (msg, signals[CONNECTED], 0);
+}
+
static void
connection_disconnected (SoupServerMessage *msg)
{
@@ -444,7 +467,11 @@ soup_server_message_new (SoupServerConnection *conn)
msg = g_object_new (SOUP_TYPE_SERVER_MESSAGE, NULL);
msg->conn = g_object_ref (conn);
+ msg->io_data = soup_server_connection_get_io_data (msg->conn);
+ g_signal_connect_object (conn, "connected",
+ G_CALLBACK (connection_connected),
+ msg, G_CONNECT_SWAPPED);
g_signal_connect_object (conn, "disconnected",
G_CALLBACK (connection_disconnected),
msg, G_CONNECT_SWAPPED);
@@ -529,7 +556,6 @@ soup_server_message_read_request (SoupServerMessage *msg,
SoupMessageIOCompletionFn completion_cb,
gpointer user_data)
{
- msg->io_data = soup_server_connection_get_io_data (msg->conn);
soup_server_message_io_read_request (msg->io_data, msg, completion_cb, user_data);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]