projects
/
svn42.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
date in graph
[svn42.git]
/
go
/
r3-netstatus
/
main.go
diff --git
a/go/r3-netstatus/main.go
b/go/r3-netstatus/main.go
index
b65e96e
..
563f94d
100644
(file)
--- a/
go/r3-netstatus/main.go
+++ b/
go/r3-netstatus/main.go
@@
-9,7
+9,7
@@
import (
"time"
"fmt"
//~ "./brain"
"time"
"fmt"
//~ "./brain"
- r3events "svn.spreadspace.org/realraum/go.svn/r3-eventbroker_zmq/r3events"
+ r3events "svn.spreadspace.org/realraum/go.svn/r3events"
)
type SpaceState struct {
)
type SpaceState struct {
@@
-40,10
+40,8
@@
func init() {
flag.StringVar(&r3eventssub_port_, "eventsubport", "tcp://wuzzler.realraum.at:4244", "zmq address to subscribe r3events")
flag.StringVar(&brain_connect_addr_, "brainconnect", "tcp://wuzzler.realraum.at:4245", "address to ask about most recent stored events")
flag.BoolVar(&enable_syslog_, "syslog", false, "enable logging to syslog")
flag.StringVar(&r3eventssub_port_, "eventsubport", "tcp://wuzzler.realraum.at:4244", "zmq address to subscribe r3events")
flag.StringVar(&brain_connect_addr_, "brainconnect", "tcp://wuzzler.realraum.at:4245", "address to ask about most recent stored events")
flag.BoolVar(&enable_syslog_, "syslog", false, "enable logging to syslog")
- flag.BoolVar(&enable_debug_, "debug", false, "enable debug logging")
+ flag.BoolVar(&enable_debug_, "debug", false, "enable debug output")
flag.Parse()
flag.Parse()
- if enable_syslog_ { LogEnableSyslog(); r3xmppbot.LogEnableSyslog() }
- if enable_debug_ { LogEnableDebuglog(); r3xmppbot.LogEnableDebuglog() }
}
//-------
}
//-------
@@
-66,7
+64,7
@@
func EventToXMPP(ps *pubsub.PubSub, xmpp_presence_events_chan_ chan <- interface
defer func() {
if x := recover(); x != nil {
defer func() {
if x := recover(); x != nil {
- Debug_.Printf("handleIncomingXMPPStanzas: run time panic: %v", x)
+ Syslog_.Printf("handleIncomingXMPPStanzas: run time panic: %v", x)
ps.Unsub(events, "presence","door","buttons","updateinterval")
close(xmpp_presence_events_chan_)
}
ps.Unsub(events, "presence","door","buttons","updateinterval")
close(xmpp_presence_events_chan_)
}
@@
-83,7
+81,7
@@
func EventToXMPP(ps *pubsub.PubSub, xmpp_presence_events_chan_ chan <- interface
xmpp_presence_events_chan_ <- r3xmppbot.XMPPStatusEvent{r3xmppbot.ShowNotAvailabe, "Nobody is here"}
for eventinterface := range(events) {
xmpp_presence_events_chan_ <- r3xmppbot.XMPPStatusEvent{r3xmppbot.ShowNotAvailabe, "Nobody is here"}
for eventinterface := range(events) {
- Debug_.Println("event2xmpp", eventinterface)
+ Debug_.Printf("event2xmpp: %T %+v", eventinterface, eventinterface)
switch event := eventinterface.(type) {
case r3events.PresenceUpdate:
present = event.Present
switch event := eventinterface.(type) {
case r3events.PresenceUpdate:
present = event.Present
@@
-119,7
+117,18
@@
func EventToXMPP(ps *pubsub.PubSub, xmpp_presence_events_chan_ chan <- interface
}
}
}
}
+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 main() {
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()}
zmqctx, zmqsub := ZmqsInit(r3eventssub_port_)
defer zmqctx.Close()
if zmqsub != nil {defer zmqsub.Close()}
@@
-143,7
+152,7
@@
func main() {
} else {
fmt.Println(xmpperr)
fmt.Println("XMPP Bot disabled")
} else {
fmt.Println(xmpperr)
fmt.Println("XMPP Bot disabled")
- Syslog_.Printf("XMPP Bot disabled due to error: %s", xmpperr)
+ Syslog_.Printf("XMPP Bot disabled due to error: %s", xmpperr.Error())
}
// --- get update on most recent events ---
}
// --- get update on most recent events ---