Official cwtch.im peer and server implementations. https://cwtch.im
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

appBridge.go 867B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package app
  2. import "cwtch.im/cwtch/event"
  3. import "git.openprivacy.ca/openprivacy/libricochet-go/log"
  4. const (
  5. // DestApp should be used as a destination for IPC messages that are for the application itself an not a peer
  6. DestApp = "app"
  7. )
  8. type applicationBridge struct {
  9. applicationCore
  10. bridge event.IPCBridge
  11. handle func(*event.Event)
  12. }
  13. func (ab *applicationBridge) listen() {
  14. log.Infoln("ab.listen()")
  15. for {
  16. ipcMessage, ok := ab.bridge.Read()
  17. log.Debugf("listen() got %v for %v\n", ipcMessage.Message.EventType, ipcMessage.Dest)
  18. if !ok {
  19. log.Debugln("exiting appBridge.listen()")
  20. return
  21. }
  22. if ipcMessage.Dest == DestApp {
  23. ab.handle(&ipcMessage.Message)
  24. } else {
  25. if eventBus, exists := ab.eventBuses[ipcMessage.Dest]; exists {
  26. eventBus.PublishLocal(ipcMessage.Message)
  27. }
  28. }
  29. }
  30. }
  31. func (ab *applicationBridge) Shutdown() {
  32. }