+func ParseZMQr3Event(lines [][]byte, ps *pubsub.PubSub) {
+ evnt, pubsubcat, err := r3events.UnmarshalByteByte2Event(lines)
+ Debug_.Printf("ParseZMQr3Event: %s %s %s", evnt, pubsubcat, err)
+ if err != nil { return }
+ ps.Pub(evnt, pubsubcat)
+}
+
+func QueryLatestEventsAndInjectThem(ps *pubsub.PubSub, zmqctx *zmq.Context) {
+ answ := ZmqsAskQuestionsAndClose(zmqctx, brain_connect_addr_, [][][]byte{
+ [][]byte{[]byte("BackdoorAjarUpdate")},
+ [][]byte{[]byte("DoorCommandEvent")},
+ [][]byte{[]byte("DoorLockUpdate")},
+ [][]byte{[]byte("DoorAjarUpdate")},
+ [][]byte{[]byte("PresenceUpdate")},
+ [][]byte{[]byte("IlluminationSensorUpdate")},
+ [][]byte{[]byte("TempSensorUpdate")}})
+ for _, a := range(answ) {
+ ParseZMQr3Event(a, ps)
+ }
+}
+
+func main() {
+ if enable_syslog_ { LogEnableSyslog(); r3xmppbot.LogEnableSyslog() }
+ if enable_debug_ { LogEnableDebuglog(); r3xmppbot.LogEnableDebuglog() }
+ Syslog_.Print("started")
+ defer Syslog_.Print("exiting")
+ zmqctx, zmqsub := ZmqsInit(r3eventssub_port_)
+ defer zmqctx.Close()
+ if zmqsub != nil {defer zmqsub.Close()}
+ if zmqsub == nil {
+ panic("zmq sockets must not be nil !!")
+ }
+
+ ps := pubsub.New(10)