diff options
author | fiaxh <git@mx.ax.lt> | 2017-03-02 15:37:32 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-03-02 15:37:32 +0100 |
commit | 56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d (patch) | |
tree | 0bd0c2c80cb81179c26282fb3fbe8fd22983f40b /vala-xmpp/src/core/stanza_writer.vala | |
download | dino-56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d.tar.gz dino-56bc45ce4d07a7a9a415e9dc8ad2f7c3f3c9e48d.zip |
Initial commit
Diffstat (limited to 'vala-xmpp/src/core/stanza_writer.vala')
-rw-r--r-- | vala-xmpp/src/core/stanza_writer.vala | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vala-xmpp/src/core/stanza_writer.vala b/vala-xmpp/src/core/stanza_writer.vala new file mode 100644 index 00000000..625f42e2 --- /dev/null +++ b/vala-xmpp/src/core/stanza_writer.vala @@ -0,0 +1,29 @@ +namespace Xmpp.Core { +public class StanzaWriter { + private OutputStream output; + + private NamespaceState ns_state = new NamespaceState(); + + public StanzaWriter.for_stream(OutputStream output) { + this.output = output; + } + + public void write_node(StanzaNode node) throws XmlError { + try { + lock(output) { + output.write_all(node.to_xml().data, null); + } + } catch (GLib.IOError e) { + throw new XmlError.IO_ERROR(@"IOError in GLib: $(e.message)"); + } + } + + public async void write(string s) throws XmlError { + try { + output.write_all(s.data, null); + } catch (GLib.IOError e) { + throw new XmlError.IO_ERROR(@"IOError in GLib: $(e.message)"); + } + } +} +}
\ No newline at end of file |