Allow "GIO-style" chained I/O with websockets
@pborelli
Submitted by Paolo Borelli Assigned to libsoup-maint@gnome.bugs
Link to original bug (#752503)
Description
My Use case is the following:
I have an existing server that is written using GIO-style chained callbacks, in pseudocode:
write_first_message() { my_connection.write_message(write_second_message) }
write_second_message() { if (!write.finish()) error()
my_connection.write_message(write_third_message) }
Now I would like to add websocket support and my plan was to have a MyWebsocketConnection which implements the same interface as MyConnection (write_message_async/read_message_async)
Unfortunately the current websocket API completely hides the outgoing message queues and only allows to send messages in a "fire-and-forget" way.
I can emulate read_message_async using the message signal, but for write there is no way to know. I guess one trivial way would be to make my write_message_async always succeed and call its callback immediately, but that is kind of ugly since it does not allow proper error reporting.
The attached patch is a proof of concept to add a gio-style api to SoupWebsocketConnection
Version: 2.51.x