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.

35 lines
705B

  1. package app
  2. import "cwtch.im/cwtch/event"
  3. import "git.openprivacy.ca/openprivacy/libricochet-go/log"
  4. type applicationBridge struct {
  5. applicationCore
  6. bridge event.IPCBridge
  7. handle func(*event.Event)
  8. }
  9. func (ab *applicationBridge) listen() {
  10. log.Infoln("ab.listen()")
  11. for {
  12. ipcMessage, ok := ab.bridge.Read()
  13. log.Debugf("listen() got %v for %v\n", ipcMessage.Message.EventType, ipcMessage.Dest)
  14. if !ok {
  15. return
  16. }
  17. if ipcMessage.Dest == DestApp {
  18. ab.handle(&ipcMessage.Message)
  19. } else {
  20. if eventBus, exists := ab.eventBuses[ipcMessage.Dest]; exists {
  21. eventBus.PublishLocal(ipcMessage.Message)
  22. }
  23. }
  24. }
  25. }
  26. func (ab *applicationBridge) Shutdown() {
  27. ab.bridge.Shutdown()
  28. }