diff options
author | Marvin W <git@larma.de> | 2023-01-31 15:13:12 +0100 |
---|---|---|
committer | Marvin W <git@larma.de> | 2023-02-07 10:50:45 +0100 |
commit | d76e12b215eb62e4eda5a0f92fbf5c1bd7c1848e (patch) | |
tree | 8037cd613ccea827d8d1895b82a2c0dd65a75a14 /xmpp-vala/src/core | |
parent | 18321ed15ce782ff5d1f24de9f2fb459d714d125 (diff) | |
download | dino-d76e12b215eb62e4eda5a0f92fbf5c1bd7c1848e.tar.gz dino-d76e12b215eb62e4eda5a0f92fbf5c1bd7c1848e.zip |
Add priority for and allow cancellation of outgoing stanzas
Diffstat (limited to 'xmpp-vala/src/core')
-rw-r--r-- | xmpp-vala/src/core/io_xmpp_stream.vala | 12 | ||||
-rw-r--r-- | xmpp-vala/src/core/stanza_writer.vala | 16 | ||||
-rw-r--r-- | xmpp-vala/src/core/xmpp_stream.vala | 4 |
3 files changed, 16 insertions, 16 deletions
diff --git a/xmpp-vala/src/core/io_xmpp_stream.vala b/xmpp-vala/src/core/io_xmpp_stream.vala index 208e8053..9c58a46b 100644 --- a/xmpp-vala/src/core/io_xmpp_stream.vala +++ b/xmpp-vala/src/core/io_xmpp_stream.vala @@ -1,7 +1,7 @@ using Gee; public interface Xmpp.WriteNodeFunc : Object { - public abstract async void write_stanza(XmppStream stream, StanzaNode node) throws IOError; + public abstract async void write_stanza(XmppStream stream, StanzaNode node, int io_priority = Priority.DEFAULT, Cancellable? cancellable = null) throws IOError; } public abstract class Xmpp.IoXmppStream : XmppStream { @@ -44,22 +44,22 @@ public abstract class Xmpp.IoXmppStream : XmppStream { } [Version (deprecated = true, deprecated_since = "0.1", replacement = "write_async")] - public override void write(StanzaNode node) { - write_async.begin(node, (obj, res) => { + public override void write(StanzaNode node, int io_priority = Priority.DEFAULT) { + write_async.begin(node, io_priority, null, (obj, res) => { try { write_async.end(res); } catch (Error e) { } }); } - public override async void write_async(StanzaNode node) throws IOError { + public override async void write_async(StanzaNode node, int io_priority = Priority.DEFAULT, Cancellable? cancellable = null) throws IOError { if (write_obj != null) { - yield write_obj.write_stanza(this, node); + yield write_obj.write_stanza(this, node, io_priority, cancellable); } else { StanzaWriter? writer = this.writer; if (writer == null) throw new IOError.NOT_CONNECTED("trying to write, but no stream open"); log.node("OUT", node, this); - yield ((!)writer).write_node(node); + yield ((!)writer).write_node(node, io_priority, cancellable); } } diff --git a/xmpp-vala/src/core/stanza_writer.vala b/xmpp-vala/src/core/stanza_writer.vala index 5b926a93..aecf8983 100644 --- a/xmpp-vala/src/core/stanza_writer.vala +++ b/xmpp-vala/src/core/stanza_writer.vala @@ -12,11 +12,11 @@ public class StanzaWriter { this.output = output; } - public async void write_node(StanzaNode node) throws IOError { - yield write_data(node.to_xml().data); + public async void write_node(StanzaNode node, int io_priority = Priority.DEFAULT, Cancellable? cancellable = null) throws IOError { + yield write_data(node.to_xml().data, io_priority, cancellable); } - public async void write_nodes(StanzaNode node1, StanzaNode node2) throws IOError { + public async void write_nodes(StanzaNode node1, StanzaNode node2, int io_priority = Priority.DEFAULT, Cancellable? cancellable = null) throws IOError { var data1 = node1.to_xml().data; var data2 = node2.to_xml().data; @@ -29,21 +29,21 @@ public class StanzaWriter { concat[i++] = datum; } - yield write_data(concat); + yield write_data(concat, io_priority, cancellable); } - public async void write(string s) throws IOError { - yield write_data(s.data); + public async void write(string s, int io_priority = Priority.DEFAULT, Cancellable? cancellable = null) throws IOError { + yield write_data(s.data, io_priority, cancellable); } - private async void write_data(owned uint8[] data) throws IOError { + private async void write_data(owned uint8[] data, int io_priority = Priority.DEFAULT, Cancellable? cancellable = null) throws IOError { if (running) { queue.push_tail(new SourceFuncWrapper(write_data.callback)); yield; } running = true; try { - yield output.write_all_async(data, 0, null, null); + yield output.write_all_async(data, io_priority, cancellable, null); } catch (IOError e) { cancel(); throw e; diff --git a/xmpp-vala/src/core/xmpp_stream.vala b/xmpp-vala/src/core/xmpp_stream.vala index 6370554f..322fb016 100644 --- a/xmpp-vala/src/core/xmpp_stream.vala +++ b/xmpp-vala/src/core/xmpp_stream.vala @@ -37,9 +37,9 @@ public abstract class Xmpp.XmppStream { public abstract async StanzaNode read() throws IOError; [Version (deprecated = true, deprecated_since = "0.1", replacement = "write_async")] - public abstract void write(StanzaNode node); + public abstract void write(StanzaNode node, int io_priority = Priority.DEFAULT); - public abstract async void write_async(StanzaNode node) throws IOError; + public abstract async void write_async(StanzaNode node, int io_priority = Priority.DEFAULT, Cancellable? cancellable = null) throws IOError; public abstract async void setup() throws IOError; |