anotherim-desktop/xmpp-vala/src/core/stanza_writer.vala

27 lines
726 B
Vala
Raw Normal View History

2017-03-02 14:37:32 +00:00
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)");
}
}
}
}