aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/core/stanza_writer.vala
blob: e67920dbdb3cc38caee77c64b34e9114031636cc (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
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)");
        }
    }
}
}