if stanza.GetHeader() == nil {
continue
}
- if stanza.GetHeader().Type == "subscribe" {
- xmppout <- botdata.makeXMPPPresence(stanza.GetHeader().From, "subscribed")
+ switch stanza.GetHeader().Type {
+ case "subscribe":
+ xmppout <- botdata.makeXMPPPresence(stanza.GetHeader().From, "subscribed")
+ jabber_events <- JabberEvent{stanza.GetHeader().From, true, R3NoChange, false}
+ xmppout <- botdata.makeXMPPPresence(stanza.GetHeader().From, "subscribe")
+ case "unsubscribe", "unsubscribed":
+ jabber_events <- JabberEvent{stanza.GetHeader().From, false, R3NoInfo, false}
+ botdata.jid_lastauthtime_[stanza.GetHeader().From] = 0 //logout
+ xmppout <- botdata.makeXMPPPresence(stanza.GetHeader().From, "unsubscribe")
+ case "unavailable":
+ jabber_events <- JabberEvent{stanza.GetHeader().From, false, R3NoChange, false}
+ botdata.jid_lastauthtime_[stanza.GetHeader().From] = 0 //logout
+ default:
+ jabber_events <- JabberEvent{stanza.GetHeader().From, true, R3NoChange, false}
}
- jabber_events <- JabberEvent{stanza.GetHeader().From, stanza.GetHeader().Type != "unavailable", R3NoChange, false}
- if stanza.GetHeader().Type == "unavailable" { botdata.jid_lastauthtime_[stanza.GetHeader().From] = 0} //logout if offline
case *xmpp.Iq:
if stanza.GetHeader() == nil {
continue
return nil, nil, err
}
- err = botdata.xmppclient_.StartSession(false, &xmpp.Presence{})
+ err = botdata.xmppclient_.StartSession(true, &xmpp.Presence{})
if err != nil {
log.Println("'Error StartSession:", err)
return nil, nil, err
}
+ roster := xmpp.Roster(botdata.xmppclient_)
+ for _, entry := range roster {
+ if entry.Subscription == "from" {
+ botdata.xmppclient_.Out <- botdata.makeXMPPPresence(entry.Jid, "subscribe")
+ }
+ if entry.Subscription == "none" {
+ delete(botdata.realraum_jids_, entry.Jid)
+ }
+ }
+
presence_events := make(chan interface{},1)
jabber_events := make(chan JabberEvent,1)