diff --git a/lib.go b/lib.go index 841be96..77b546e 100644 --- a/lib.go +++ b/lib.go @@ -21,6 +21,7 @@ import ( ) var application app.Application +var appBusQueue event.Queue var acnQueue event.Queue var contactEventsQueue event.Queue @@ -59,6 +60,16 @@ func StartCwtch(appDir string, torPath string) { newApp := app.NewApp(acn, appDir) acnQueue = event.NewQueue() newApp.GetPrimaryBus().Subscribe(event.ACNStatus, acnQueue) + + appBusQueue = event.NewQueue() + newApp.GetPrimaryBus().Subscribe(event.NewPeer, appBusQueue) + newApp.GetPrimaryBus().Subscribe(event.PeerError, appBusQueue) + newApp.GetPrimaryBus().Subscribe(event.AppError, appBusQueue) + newApp.GetPrimaryBus().Subscribe(event.ACNStatus, appBusQueue) + newApp.GetPrimaryBus().Subscribe(event.ReloadDone, appBusQueue) + newApp.GetPrimaryBus().Subscribe(event.ACNVersion, appBusQueue) + + // Lol this wasn't an intended use peer.DefaultEventsToHandle = []event.Type{ event.EncryptedGroupMessage, event.NewMessageFromPeer, @@ -89,6 +100,12 @@ func ACNEvents() string { } } +// GetAppBusEvent blocks until an event +func GetAppBusEvent() string { + event := appBusQueue.Next() + return fmt.Sprintf("%v", event) +} + //export c_GetProfiles func c_GetProfiles() *C.char { return C.CString(GetProfiles())