public async Task EnsureFayeConnection() {
            if (Faye == null || !Faye.IsConnected) {
                Window.Current.Content = connectView;

                Faye = MetroFaye.Faye.CreateClient(new Uri(Endpoints.PushAddress));
                Faye.PrimaryReciever = MessageController;
                Faye.Disconnected += FayeOnDisconnected;

                var error = false;
                try {
                    await Faye.ConnectAsync();
                } catch {
                    error = true;
                }
                if (error) {
                    await EnsureFayeConnection();
                    return;
                }
            }

            Window.Current.Content = MainFrame;
        }
 public void Callback(MessageHandler handler, JObject response) {
     waiter.Set();
 }
 private async void FayeOnDisconnected() {
     Faye = null;
     await MainFrame.Dispatcher.RunAsync(CoreDispatcherPriority.Low, async delegate {
         await EnsureFayeConnection();
         if (SessionController.CurrentSession == null) return;
         ConnectSession(SessionController.CurrentSession);
         if (MessageController.CurrentCloud == null) return;
         await MessageController.CurrentCloud.EnsureLoaded();
     });
 }