summaryrefslogtreecommitdiff
path: root/libsoup
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2022-07-19 10:22:06 +0200
committerCarlos Garcia Campos <cgarcia@igalia.com>2022-08-12 11:03:48 +0200
commit3ae802e6026a8c84637c1fde6a0ee88bd06a2056 (patch)
treecf12f757af46fcefcdc89b2a25fa009889fbf2ff /libsoup
parent85ef40fe5af14a35622325edf298b2a901351cbb (diff)
downloadlibsoup-3ae802e6026a8c84637c1fde6a0ee88bd06a2056.tar.gz
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.
Diffstat (limited to 'libsoup')
-rw-r--r--libsoup/server/soup-server-connection.c14
-rw-r--r--libsoup/server/soup-server-message.c28
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:
@@ -394,6 +409,14 @@ soup_server_message_class_init (SoupServerMessageClass *klass)
}
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)
{
msg->io_data = NULL;
@@ -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);
}