Compare commits
5 Commits
eccf505942
...
0490e0a087
| Author | SHA1 | Date |
|---|---|---|
|
|
0490e0a087 | |
|
|
7d5b58fc8d | |
|
|
e4acd3d349 | |
|
|
0aac61b1cc | |
|
|
f1443ca444 |
|
|
@ -0,0 +1,13 @@
|
|||
package xmpp
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
const (
|
||||
NSPing = "urn:xmpp:ping"
|
||||
)
|
||||
|
||||
type Ping struct {
|
||||
XMLName xml.Name `xml:"urn:xmpp:ping ping"`
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package xmpp
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
const (
|
||||
NSRemoteRosterManager = "urn:xmpp:tmp:roster-management:0"
|
||||
|
||||
RemoteRosterManagerTypeRequest = "request"
|
||||
RemoteRosterManagerTypeAllowed = "allowed"
|
||||
RemoteRosterManagerTypeRejected = "rejected"
|
||||
)
|
||||
|
||||
// XEP-0321: Remote Roster Manager
|
||||
|
||||
type RemoteRosterManagerQuery struct {
|
||||
XMLName xml.Name `xml:"urn:xmpp:tmp:roster-management:0 query"`
|
||||
Reason string `xml:"reason,attr,omitempty"`
|
||||
Type string `xml:"type,attr"`
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package xmpp
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
const (
|
||||
NSRoster = "jabber:iq:roster"
|
||||
|
||||
RosterSubscriptionBoth = "both"
|
||||
RosterSubscriptionFrom = "from"
|
||||
RosterSubscriptionTo = "to"
|
||||
RosterSubscriptionRemove = "remove"
|
||||
)
|
||||
|
||||
type RosterQuery struct {
|
||||
XMLName xml.Name `xml:"jabber:iq:roster query"`
|
||||
Items []RosterItem `xml:"item"`
|
||||
}
|
||||
|
||||
type RosterItem struct {
|
||||
JID string `xml:"jid,attr"`
|
||||
Name string `xml:"name,attr,omitempty"`
|
||||
Subscription string `xml:"subscription,attr"`
|
||||
Groupes []string `xml:"group"`
|
||||
}
|
||||
|
|
@ -189,4 +189,5 @@ var (
|
|||
ErrorNotAuthorized = ErrorCondition{nsErrorStanzas, "not-authorized"}
|
||||
ErrorConflict = ErrorCondition{nsErrorStanzas, "conflict"}
|
||||
ErrorNotAcceptable = ErrorCondition{nsErrorStanzas, "not-acceptable"}
|
||||
ErrorForbidden = ErrorCondition{nsErrorStanzas, "forbidden"}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -170,12 +170,16 @@ func (x *XMPP) sender() {
|
|||
// Close the stream. Note: relies on common element name for all types of
|
||||
// XMPP connection.
|
||||
log.Println("Close XMPP stream")
|
||||
x.stream.SendEnd(&xml.EndElement{xml.Name{"stream", "stream"}})
|
||||
x.Close()
|
||||
}
|
||||
|
||||
func (x *XMPP) receiver() {
|
||||
|
||||
defer close(x.In)
|
||||
defer func() {
|
||||
log.Println("Close XMPP receiver")
|
||||
x.Close()
|
||||
close(x.In)
|
||||
}()
|
||||
|
||||
for {
|
||||
start, err := x.stream.Next()
|
||||
|
|
@ -215,8 +219,11 @@ func (x *XMPP) receiver() {
|
|||
x.In <- v
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("Close XMPP receiver")
|
||||
func (x *XMPP) Close() {
|
||||
log.Println("Close XMPP")
|
||||
x.stream.SendEnd(&xml.EndElement{xml.Name{"stream", "stream"}})
|
||||
}
|
||||
|
||||
// BUG(matt): Filter channels are not closed when the stream is closed.
|
||||
|
|
|
|||
Loading…
Reference in New Issue