From 4fa114cd1efcba90054247f30fad957c8f0ec06d Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 22 May 2023 21:04:04 +0200 Subject: Move stream logic to new xmpp/stream.go --- xmpp/stream.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 xmpp/stream.go (limited to 'xmpp/stream.go') diff --git a/xmpp/stream.go b/xmpp/stream.go new file mode 100644 index 0000000..803071a --- /dev/null +++ b/xmpp/stream.go @@ -0,0 +1,33 @@ +package xmpp + +import ( + "encoding/xml" + "log" +) + +func sendStreamStart(enc *encoder, jid string) xml.EndElement { + start := xml.StartElement{ + xml.Name{"jabber:client", "stream:stream"}, + []xml.Attr{ + xml.Attr{xml.Name{"", "from"}, jid}, + xml.Attr{xml.Name{"", "to"}, domainpart(jid)}, + xml.Attr{xml.Name{"", "version"}, "1.0"}, + xml.Attr{xml.Name{"", "xml:lang"}, "en"}, + xml.Attr{xml.Name{"", "xmlns:stream"}, "http://etherx.jabber.org/streams"}, + }, + } + + err := enc.encodeNow(start) + if err != nil { + log.Println("Could not encode stream start!") + } + + return start.End() +} + +func sendStreamEnd(enc *encoder, end xml.EndElement) { + err := enc.encodeNow(end) + if err != nil { + log.Println("Could not encode stream end!") + } +} -- cgit v1.2.3-70-g09d2