summaryrefslogtreecommitdiff
path: root/xmpp/stream.go
blob: 803071a3023f548fa0fd3f0e2cd0f7e66fea3623 (plain)
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
30
31
32
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!")
	}
}