private void ProcessAnswer(bool answer, String username) { if (answer) { SubscribeRq request = new SubscribeRq { subscribe = true, username = username }; _appContext.ConnectionManager.Connection.RequestAsync<SubscribeRq, SubscribeRs>(request, SubscribeRequestResponseHandler); } else { SubscribeRq request = new SubscribeRq { subscribe = false, username = username }; _appContext.ConnectionManager.Connection.RequestAsync<SubscribeRq, SubscribeRs>(request, SubscribeRequestResponseHandler); } }
private void SubscribePersonResponseHandler(SubscribeRq request, SubscribeRs response, Exception e, Person person) { if (e == null) { person.SubscriptionStatus = "subscribe"; Logger.Debug("Succeeded in sending subscribe request for " + person.Username); } else { Logger.Error("Failed to subscribe to " + person.Username + " : " + e.Message, e); } }
private void SendSubscribe(bool subscribe) { UiHelper.Disabler.DisableInputs(true, "Updating"); ThreadPool.QueueUserWorkItem(state => { try { SubscribeRq request = new SubscribeRq {subscribe = subscribe, username = Team.Username}; GwupeClientAppContext.CurrentAppContext.ConnectionManager.Connection .Request<SubscribeRq, SubscribeRs>(request); // Hack the answer (actual notify comes through a little later) Dispatcher.Invoke(new Action(() => { Team.Player = subscribe ? PlayerMembership.player : PlayerMembership.none; })); // look through notifications to make sure that none related to this are there foreach ( var notification in GwupeClientAppContext.CurrentAppContext.NotificationManager.Notifications) { if (notification is JoinTeamNotification) { var teamNotification = notification as JoinTeamNotification; if (!String.IsNullOrEmpty(teamNotification.TeamUsername) && teamNotification.TeamUsername.Equals(Team.Username)) { // this is the one, delete and break GwupeClientAppContext.CurrentAppContext.NotificationManager.DeleteNotification( notification); break; } } } } catch (Exception ex) { Logger.Error( "Failed to " + (subscribe ? "accept" : "decline") + " subscription to " + Team.Username, ex); UiHelper.Validator.SetError("Failed to send subscription status to server."); } finally { UiHelper.Disabler.DisableInputs(false); } }); }
private void SubscribeRequestResponseHandler(SubscribeRq request, SubscribeRs response, Exception e) { if (e != null) { Logger.Error("Failed to send subscribe answer to " + request.username + " : " + e.Message, e); } }