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.

eventmanageripc.go 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package event
  2. type ipcManager struct {
  3. manager Manager
  4. onion string
  5. ipcBridge IPCBridge
  6. }
  7. // NewIPCEventManager returns an EvenetManager that also pipes events over and supplied IPCBridge
  8. func NewIPCEventManager(bridge IPCBridge, onion string) Manager {
  9. em := &ipcManager{onion: onion, ipcBridge: bridge, manager: NewEventManager()}
  10. return em
  11. }
  12. // IPCEventManagerFrom returns an IPCEventManger from the supplied manager and IPCBridge
  13. func IPCEventManagerFrom(bridge IPCBridge, onion string, manager Manager) Manager {
  14. em := &ipcManager{onion: onion, ipcBridge: bridge, manager: manager}
  15. return em
  16. }
  17. func (ipcm *ipcManager) Publish(ev Event) {
  18. ipcm.manager.Publish(ev)
  19. message := &IPCMessage{Dest: ipcm.onion, Message: ev}
  20. ipcm.ipcBridge.Write(message)
  21. }
  22. func (ipcm *ipcManager) PublishLocal(ev Event) {
  23. ipcm.manager.Publish(ev)
  24. }
  25. func (ipcm *ipcManager) Subscribe(eventType Type, eventChan chan Event) {
  26. ipcm.manager.Subscribe(eventType, eventChan)
  27. }
  28. func (ipcm *ipcManager) Shutdown() {
  29. ipcm.manager.Shutdown()
  30. }