aboutsummaryrefslogtreecommitdiff
path: root/vala-xmpp/src/core/stanza_writer.vala
blob: 625f42e2307ddd6b72ef6e27f970002a67eb230c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)");
        }
    }
}
}