Inheritance: API.Request
コード例 #1
0
ファイル: SubscribeProcessor.cs プロジェクト: gwupe/Gwupe
 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);
     }
 }
コード例 #2
0
ファイル: RosterManager.cs プロジェクト: gwupe/Gwupe
 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);
     }
 }
コード例 #3
0
        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);
                }
            });
        }
コード例 #4
0
ファイル: SubscribeProcessor.cs プロジェクト: gwupe/Gwupe
 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);
     }
 }