getAppBusEvents for gomobile

This commit is contained in:
Dan Ballard 2021-01-20 12:05:37 -08:00
parent 120dc5f468
commit 9c7a22d472
1 changed files with 17 additions and 0 deletions

17
lib.go
View File

@ -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())