X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=go%2Fr3-eventbroker_zmq%2Fsockettoevent.go;h=84dff4a500a719079667abdc6a34927110c05231;hb=03f11406495d2de6340f0331f91ebfd25fbe67ed;hp=f2e7a200df35756d3635493835c1ae8e3088e38f;hpb=845254e617b714552edbf860632f0e763a40d1a5;p=svn42.git diff --git a/go/r3-eventbroker_zmq/sockettoevent.go b/go/r3-eventbroker_zmq/sockettoevent.go index f2e7a20..84dff4a 100644 --- a/go/r3-eventbroker_zmq/sockettoevent.go +++ b/go/r3-eventbroker_zmq/sockettoevent.go @@ -10,6 +10,7 @@ import ( "encoding/json" pubsub "github.com/tuxychandru/pubsub" zmq "github.com/vaughan0/go-zmq" + "log" ) var ( @@ -26,13 +27,6 @@ var ( ) -type PresenceUpdate struct { - Present bool - Ts int64 -} -func (s PresenceUpdate) Serialize() string - - type DoorLockUpdate struct { DoorID byte Locked bool @@ -100,12 +94,13 @@ func ParseSocketInputLine(lines [][]byte, ps *pubsub.PubSub, keylookup_socket *z var tidbit interface{} ts := time.Now().Unix() if len(lines) < 1 { return } + log.Print("ParseSocketInputLine",string(lines[0])) switch string(lines[0]) { case "State:": - if len(lines) < 2 { continue } + if len(lines) < 2 { return } parseSocketInputLine_State(lines[1:], ps, ts) case "Status:": - if len(lines) < 3 { continue } + if len(lines) < 3 { return } tidbit = DoorLockUpdate{0, string(lines[1]) == "closed", ts} //~ brn.Oboite("door", tidbit) ps.Pub(tidbit, "door") @@ -113,23 +108,21 @@ func ParseSocketInputLine(lines [][]byte, ps *pubsub.PubSub, keylookup_socket *z //~ brn.Oboite("door", tidbit) ps.Pub(tidbit, "door") case "Info(card):": - if len(lines) < 3 { continue } - if string(lines[2]) != "found" { - continue - } + if len(lines) < 3 { return } + if string(lines[2]) != "found" { return } match_cardid := re_cardid_.FindSubmatch(lines[1]) if len(match_cardid) > 1 { // PreCondition: same thread/goroutinge as created keylookup_socket !!!! - nick, err := keylookup_socket.LookupCardIdNick(match_cardid[1]) + nick, err := LookupCardIdNick(keylookup_socket, match_cardid[1]) if err != nil { Syslog_.Print("CardID Lookup Error",err) - nick := "Unresolvable KeyID" + nick = "Unresolvable KeyID" } // new event: toggle by user nick using card ps.Pub(DoorCommandEvent{"toggle", "Card", nick, ts},"doorcmd") } case "Info(ajar):": - if len(lines) < 5 { continue } + if len(lines) < 5 { return } tidbit = DoorAjarUpdate{0, string(lines[4]) == "shut", ts} //~ brn.Oboite("door", tidbit) ps.Pub(tidbit, "door")