diff --git a/go/characters/appEventListener.go b/go/characters/appEventListener.go index 02d87b1b..827e8bcc 100644 --- a/go/characters/appEventListener.go +++ b/go/characters/appEventListener.go @@ -11,13 +11,14 @@ import ( "strconv" ) -func AppEventListener(gcd *gothings.GrandCentralDispatcher) { +func AppEventListener(gcd *gothings.GrandCentralDispatcher, subscribed chan bool) { q := event.NewEventQueue(1000) the.AppBus.Subscribe(event.NewPeer, q.EventChannel) the.AppBus.Subscribe(event.PeerError, q.EventChannel) the.AppBus.Subscribe(event.AppError, q.EventChannel) the.AppBus.Subscribe(event.ACNStatus, q.EventChannel) the.AppBus.Subscribe(event.ReloadDone, q.EventChannel) + subscribed <- true for { e := q.Next() @@ -68,6 +69,11 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) { the.Peer = the.CwtchApp.GetPeer(onion) the.EventBus = the.CwtchApp.GetEventBus(onion) + incSubscribed := make(chan bool) + go IncomingListener(&gcd.UIState, incSubscribed) + <-incSubscribed + go PresencePoller(&gcd.UIState) + gcd.UpdateMyProfile(the.Peer.GetProfile().Name, the.Peer.GetProfile().Onion, cwutil.RandomProfileImage(the.Peer.GetProfile().Onion)) if e.Data[event.Status] != "running" { the.CwtchApp.LaunchPeers() @@ -110,8 +116,6 @@ func AppEventListener(gcd *gothings.GrandCentralDispatcher) { }) } } - go IncomingListener(&gcd.UIState) - go PresencePoller(&gcd.UIState) // load ui preferences gcd.RequestSettings() diff --git a/go/characters/incominglistener.go b/go/characters/incominglistener.go index 188fdb53..14ae72a3 100644 --- a/go/characters/incominglistener.go +++ b/go/characters/incominglistener.go @@ -11,7 +11,7 @@ import ( "time" ) -func IncomingListener(uiState *gothings.InterfaceState) { +func IncomingListener(uiState *gothings.InterfaceState, subscribed chan bool) { q := event.NewEventQueue(1000) the.EventBus.Subscribe(event.NewMessageFromPeer, q.EventChannel) the.EventBus.Subscribe(event.NewMessageFromGroup, q.EventChannel) @@ -21,6 +21,7 @@ func IncomingListener(uiState *gothings.InterfaceState) { the.EventBus.Subscribe(event.JoinServer, q.EventChannel) the.EventBus.Subscribe(event.ServerStateChange, q.EventChannel) the.EventBus.Subscribe(event.PeerStateChange, q.EventChannel) + subscribed <- true for { e := q.Next() diff --git a/main.go b/main.go index 175fedd9..c353b060 100644 --- a/main.go +++ b/main.go @@ -229,7 +229,9 @@ func loadNetworkingAndFiles(gcd *gothings.GrandCentralDispatcher, service bool, if !service { the.AppBus = the.CwtchApp.GetPrimaryBus() - go characters.AppEventListener(gcd) + subscribed := make(chan bool) + go characters.AppEventListener(gcd, subscribed) + <-subscribed } if !service && !clientUI {