Merge pull request 'Remove Unused Map' (#64) from fixees into trunk
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Reviewed-on: #64
This commit is contained in:
commit
c1b7e4c75d
2
lib.go
2
lib.go
|
@ -184,7 +184,7 @@ func ReconnectCwtchForeground() {
|
||||||
// populate profile list
|
// populate profile list
|
||||||
peerList := application.ListPeers()
|
peerList := application.ListPeers()
|
||||||
for onion := range peerList {
|
for onion := range peerList {
|
||||||
eventHandler.Push(event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: onion, event.Created: event.False}))
|
eventHandler.Push(event.NewEvent(event.NewPeer, map[event.Field]string{event.Identity: onion, event.Created: event.False, "Reload": event.True}))
|
||||||
}
|
}
|
||||||
|
|
||||||
for onion := range peerList {
|
for onion := range peerList {
|
||||||
|
|
|
@ -23,11 +23,10 @@ type EventHandler struct {
|
||||||
app app.Application
|
app app.Application
|
||||||
appBusQueue event.Queue
|
appBusQueue event.Queue
|
||||||
profileEvents chan EventProfileEnvelope
|
profileEvents chan EventProfileEnvelope
|
||||||
profileQueues map[string]event.Queue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEventHandler() *EventHandler {
|
func NewEventHandler() *EventHandler {
|
||||||
eh := &EventHandler{app: nil, appBusQueue: event.NewQueue(), profileQueues: make(map[string]event.Queue), profileEvents: make(chan EventProfileEnvelope)}
|
eh := &EventHandler{app: nil, appBusQueue: event.NewQueue(), profileEvents: make(chan EventProfileEnvelope)}
|
||||||
return eh
|
return eh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +78,10 @@ func (eh *EventHandler) handleAppBusEvent(e *event.Event) string {
|
||||||
onion := e.Data[event.Identity]
|
onion := e.Data[event.Identity]
|
||||||
profile := eh.app.GetPeer(e.Data[event.Identity])
|
profile := eh.app.GetPeer(e.Data[event.Identity])
|
||||||
log.Debug("New Peer Event: %v", e)
|
log.Debug("New Peer Event: %v", e)
|
||||||
eh.startHandlingPeer(onion)
|
|
||||||
|
if e.Data["Reload"] != event.True {
|
||||||
|
eh.startHandlingPeer(onion)
|
||||||
|
}
|
||||||
|
|
||||||
if e.Data[event.Created] == event.True {
|
if e.Data[event.Created] == event.True {
|
||||||
name, _ := profile.GetAttribute(attr.GetLocalScope(constants.Name))
|
name, _ := profile.GetAttribute(attr.GetLocalScope(constants.Name))
|
||||||
|
@ -345,18 +347,21 @@ func (eh *EventHandler) startHandlingPeer(onion string) {
|
||||||
eventBus.Subscribe(event.ChangePasswordError, q)
|
eventBus.Subscribe(event.ChangePasswordError, q)
|
||||||
eventBus.Subscribe(event.NewRetValMessageFromPeer, q)
|
eventBus.Subscribe(event.NewRetValMessageFromPeer, q)
|
||||||
eventBus.Subscribe(event.SetAttribute, q)
|
eventBus.Subscribe(event.SetAttribute, q)
|
||||||
eh.profileQueues[onion] = q
|
|
||||||
|
|
||||||
go eh.forwardProfileMessages(onion, q)
|
go eh.forwardProfileMessages(onion, q)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eh *EventHandler) forwardProfileMessages(onion string, q event.Queue) {
|
func (eh *EventHandler) forwardProfileMessages(onion string, q event.Queue) {
|
||||||
|
log.Infof("Launching Forwarding Goroutine for %v", onion)
|
||||||
// TODO: graceful shutdown, via an injected event of special QUIT type exiting loop/go routine
|
// TODO: graceful shutdown, via an injected event of special QUIT type exiting loop/go routine
|
||||||
for {
|
for {
|
||||||
e := q.Next()
|
e := q.Next()
|
||||||
ev := EventProfileEnvelope{Event: e, Profile: onion}
|
ev := EventProfileEnvelope{Event: e, Profile: onion}
|
||||||
eh.profileEvents <- ev
|
eh.profileEvents <- ev
|
||||||
|
if ev.Event.EventType == event.Shutdown {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue