35 lines
662 B
Go
35 lines
662 B
Go
|
package app
|
||
|
|
||
|
import "cwtch.im/cwtch/event"
|
||
|
import "git.openprivacy.ca/openprivacy/libricochet-go/log"
|
||
|
|
||
|
type applicationBridge struct {
|
||
|
applicationCore
|
||
|
|
||
|
bridge event.IPCBridge
|
||
|
handle func(*event.Event)
|
||
|
}
|
||
|
|
||
|
func (ab *applicationBridge) listen() {
|
||
|
log.Infoln("ab.listen()")
|
||
|
for {
|
||
|
ipcMessage, ok := ab.bridge.Read()
|
||
|
log.Infof("listen() got %v\n", ipcMessage)
|
||
|
if !ok {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if ipcMessage.Dest == DestApp {
|
||
|
ab.handle(&ipcMessage.Message)
|
||
|
} else {
|
||
|
if eventBus, exists := ab.eventBuses[ipcMessage.Dest]; exists {
|
||
|
eventBus.PublishLocal(ipcMessage.Message)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (ab *applicationBridge) Shutdown() {
|
||
|
ab.bridge.Shutdown()
|
||
|
}
|