for {
select {
case pe := <-presence_events:
+ Debug_.Printf("handleEventsforXMPP<-presence_events: %T %+v", pe, pe)
switch pec := pe.(type) {
case xmpp.Stanza:
xmppout <- pec
}
case je := <-jabber_events:
+ Debug_.Printf("handleEventsforXMPP<-jabber_events: %T %+v", je, je)
simple_jid := removeJIDResource(je.JID)
jid_data, jid_in_map := botdata.realraum_jids_[simple_jid]
+
+ //send status if requested, even if user never changed any settings and thus is not in map
+ if last_status_msg != nil && je.StatusNow {
+ xmppout <- botdata.makeXMPPMessage(je.JID, last_status_msg, nil)
+ }
+
if jid_in_map {
- if last_status_msg != nil && (je.StatusNow || (! jid_data.Online && je.Online && jid_data.Wants == R3OnlineOnlyWithRecapInfo) ) {
+ //if R3OnlineOnlyWithRecapInfo, we want a status update when coming online
+ if last_status_msg != nil && ! jid_data.Online && je.Online && jid_data.Wants == R3OnlineOnlyWithRecapInfo {
xmppout <- botdata.makeXMPPMessage(je.JID, last_status_msg, nil)
}
jid_data.Online = je.Online
roster := xmpp.Roster(botdata.xmppclient_)
for _, entry := range roster {
+ Debug_.Print(entry)
if entry.Subscription == "from" {
botdata.xmppclient_.Out <- botdata.makeXMPPPresence(entry.Jid, "subscribe", "","")
}
}
switch string(data[0]) {
case "DoorLockUpdate":
- event = DoorLockUpdate{}
- err = json.Unmarshal(data[1],&event)
+ newevent := new(DoorLockUpdate)
+ err = json.Unmarshal(data[1],newevent)
category = "door"
+ event = *newevent
case "DoorAjarUpdate":
- event := DoorAjarUpdate{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(DoorAjarUpdate)
+ err = json.Unmarshal(data[1], newevent)
category = "door"
+ event = *newevent
case "BackdoorAjarUpdate":
- event := DoorAjarUpdate{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(BackdoorAjarUpdate)
+ err = json.Unmarshal(data[1], newevent)
category = "door"
+ event = *newevent
case "DoorCommandEvent":
- event := DoorCommandEvent{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(DoorCommandEvent)
+ err = json.Unmarshal(data[1], newevent)
category = "door"
+ event = *newevent
case "DoorProblemEvent":
- event := DoorProblemEvent{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(DoorProblemEvent)
+ err = json.Unmarshal(data[1], newevent)
category = "door"
+ event = *newevent
case "BoreDoomButtonPressEvent":
- event := BoreDoomButtonPressEvent{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(BoreDoomButtonPressEvent)
+ err = json.Unmarshal(data[1], newevent)
category = "buttons"
+ event = *newevent
case "TempSensorUpdate":
- event := TempSensorUpdate{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(TempSensorUpdate)
+ err = json.Unmarshal(data[1], newevent)
category = "sensors"
+ event = *newevent
case "IlluminationSensorUpdate":
- event := IlluminationSensorUpdate{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(IlluminationSensorUpdate)
+ err = json.Unmarshal(data[1], newevent)
category = "sensors"
+ event = *newevent
case "DustSensorUpdate":
- event := DustSensorUpdate{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(DustSensorUpdate)
+ err = json.Unmarshal(data[1], newevent)
category = "sensors"
+ event = *newevent
case "RelativeHumiditySensorUpdate":
- event := RelativeHumiditySensorUpdate{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(RelativeHumiditySensorUpdate)
+ err = json.Unmarshal(data[1], newevent)
category = "sensors"
+ event = *newevent
case "TimeTick":
- event := TimeTick{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(TimeTick)
+ err = json.Unmarshal(data[1], newevent)
category = "time"
+ event = *newevent
case "MovementSensorUpdate":
- event := MovementSensorUpdate{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(MovementSensorUpdate)
+ err = json.Unmarshal(data[1], newevent)
category = "movement"
+ event = *newevent
case "PresenceUpdate":
- event := PresenceUpdate{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(PresenceUpdate)
+ err = json.Unmarshal(data[1], newevent)
category = "presence"
+ event = *newevent
case "SomethingReallyIsMoving":
- event := SomethingReallyIsMoving{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(SomethingReallyIsMoving)
+ err = json.Unmarshal(data[1], newevent)
category = "movement"
+ event = *newevent
case "NetDHCPACK":
- event := NetDHCPACK{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(NetDHCPACK)
+ err = json.Unmarshal(data[1], newevent)
category = "network"
+ event = *newevent
case "NetGWStatUpdate":
- event := NetGWStatUpdate{}
- err = json.Unmarshal(data[1], &event)
+ newevent := new(NetGWStatUpdate)
+ err = json.Unmarshal(data[1], newevent)
category = "network"
+ event = *newevent
default:
event = nil
err = errors.New("cannot unmarshal unknown type")