aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/core/stanza_writer.vala
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/core/stanza_writer.vala')
-rw-r--r--xmpp-vala/src/core/stanza_writer.vala27
1 files changed, 27 insertions, 0 deletions
diff --git a/xmpp-vala/src/core/stanza_writer.vala b/xmpp-vala/src/core/stanza_writer.vala
new file mode 100644
index 00000000..26524d7b
--- /dev/null
+++ b/xmpp-vala/src/core/stanza_writer.vala
@@ -0,0 +1,27 @@
+namespace Xmpp.Core {
+public class StanzaWriter {
+ private OutputStream output;
+
+ 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