示例#1
0
 private void OnClickShareFacebook(GameObject go)
 {
     SocialService.GetAccessToken(SocialType.Facebook, (status, token) =>
     {
         if (status)
         {
             APIGeneric.PostFacebook(token, data.title, null, delegate(bool status1, string message)
             {
                 if (status == false)
                 {
                     DialogService.Instance.ShowDialog(new DialogMessage("Lỗi", "Gặp lỗi khi post facebook", null));
                 }
                 if (gameObject != null)
                 {
                     GameObject.Destroy(gameObject);
                 }
             });
         }
         else
         {
             DialogService.Instance.ShowDialog(new DialogMessage("Lỗi", "Không thể đăng nhập Facebook.", null));
             if (gameObject != null)
             {
                 GameObject.Destroy(gameObject);
             }
         }
     });
 }
示例#2
0
    public void StartApplication(Action <float, string> onLoadConfig)
    {
#if UNITY_WEBPLAYER
        if (!Application.isEditor && Application.isWebPlayer)
        {
            //if (!Security.PrefetchSocketPolicy(AppConfig.SocketUrl, AppConfig.SocketPort, 999))
            if (!Security.PrefetchSocketPolicy("210.245.94.106", 9933, 999))
            {
                Debug.LogError("Security Exception. Policy file load failed!");
            }
            else
            {
                Debug.LogWarning("Security Good. Policy file load success!");
            }
        }
#endif

        sleepTimeout        = Screen.sleepTimeout;
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
        setting             = new PuSetting(onLoadConfig);

        //PingManager.Instance.Load();

        PuMain.Setting.Threading.QueueOnMainThread(() =>
        {
            PuMain.Dispatcher.onWarningUpgrade += Dispatcher_onWarningUpgrade;
            PuMain.Dispatcher.onDailyGift      += Dispatcher_onDailyGift;
            PuMain.Dispatcher.onNoticeMessage  += Dispatcher_onNoticeMessage;
        });

        SocialService.SocialStart();

        currentNetworkType = Application.internetReachability;
    }
示例#3
0
        private async Task <bool> CheckIfGuilded(NetworkEntityGuid guid)
        {
            var guildStatus = await SocialService.GetCharacterMembershipGuildStatus(guid.EntityId);

            //If the query was successful then they ARE in a guild.
            return(guildStatus.ResultCode == CharacterGuildMembershipStatusResponseCode.Success);
        }
示例#4
0
 private void InitializeSocialService()
 {
     _socialService = new SocialService
     {
         ////SimulationMode = true
     };
 }
示例#5
0
        private SocialService CreateSocialService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new SocialService(userId);

            return(service);
        }
示例#6
0
        protected override void OnGuildStatusChanged(GuildStatusChangedEventModel changeArgs)
        {
            //Don't need to get the guild list if we're guildless.
            if (changeArgs.IsGuildless)
            {
                return;
            }

            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                var rosterResponseModel = await SocialService.GetGuildListAsync();

                if (!rosterResponseModel.isSuccessful)
                {
                    if (Logger.IsWarnEnabled)
                    {
                        Logger.Warn($"Failed to query guild roster. Reason: {rosterResponseModel.ResultCode}");
                    }
                    return;
                }

                //Now we can publish the roster.
                foreach (int rosterCharacterId in rosterResponseModel.Result.GuildedCharacterIds)
                {
                    NetworkEntityGuid characterGuid = NetworkEntityGuidBuilder.New()
                                                      .WithType(EntityType.Player)
                                                      .WithId(rosterCharacterId)
                                                      .Build();

                    //This is a hidden join, or the alerts would be spammed.
                    GuildJoinEventPublisher.PublishEvent(this, new CharacterJoinedGuildEventArgs(characterGuid, true));
                }
            });
        }
示例#7
0
        public static string RequestNewTwitterToken(SocialService service)
        {
            string postBody = string.Empty;

            ServicePointManager.Expect100Continue = false;

            HttpWebRequest hwr =
            (HttpWebRequest)HttpWebRequest.Create(
            @"https://api.twitter.com/oauth/request_token");

            hwr.Method = "POST";
            hwr.Headers.Add("Authorization", GetAuthHeader("https://api.twitter.com/oauth/request_token", "POST", service.Key, service.Secret, string.Empty).Split(';')[0]);
            string sh = hwr.Headers["Authorization"].ToString();
            hwr.ContentType = "application/x-www-form-urlencoded";

            hwr.Timeout = 3 * 60 * 1000;

            try
            {
                WebResponse response = hwr.GetResponse();
                StreamReader reader = new StreamReader(response.GetResponseStream());
                string responseString = reader.ReadToEnd();
                reader.Close();
                return responseString;
            }
            catch (WebException e)
            {
                return e.Message;
            }
        }
示例#8
0
 void onLoginComplete(SocialType arg1, bool arg2)
 {
     if (arg2)
     {
         GetAccessTokenWithSocial(SocialService.GetSocialNetwork(arg1).AccessToken);
     }
 }
示例#9
0
        private void InitializeAndRegisterSocialService()
        {
            var socialService = new SocialService();

            socialService.Initialize(null);

            WaveServices.RegisterService(socialService);
        }
示例#10
0
        // GET: Social
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new SocialService(userId);
            var model   = service.GetSocials();

            return(View(model));
        }
示例#11
0
 public static void GetFacebookProfile(App42ApiResultCallback callBack)
 {
     App42ApiCallback _sCallback = new App42ApiCallback(callBack);
     if (mSocialService == null)
     {
         mSocialService = GlobalContext.SERVICE_API.BuildSocialService();
     }
     mSocialService.GetFacebookProfile(GlobalContext.AccessToken, _sCallback);
 }
 public static void ConnectWithFacebook()
 {
     socialService = App42API.BuildSocialService();
     // Making facebook Permissions Array.
     string[] perms = new string[10];
     perms [0] = FBPerms.email;
     perms [1] = FBPerms.user_friends;
     socialService.DoFBOAuthAndGetToken(AppConstants.FB_APP_ID, perms, false, new LeaderBoardCallBack());
 }
示例#13
0
    public void AsyncApp42Api()
    {
        ServiceAPI sp = new ServiceAPI("43f6b65747952492b5e30056ac9539ef7c50b44c4178e7c361cfa3b20ee52095", "e09348180158fb9304906d696dec68b3e2f074747a09ec93284271627f7c2599");

        this.userService    = sp.BuildUserService();
        this.storageService = sp.BuildStorageService();
        this.pushService    = sp.BuildPushNotificationService();
        this.socialService  = sp.BuildSocialService();
    }
示例#14
0
 public SocialViewModel(string chatRoomId)
 {
     ChatRoomId = chatRoomId;
     SocialService = new SocialService();
     SocialService.ErrorOccured += (s, e) =>
     {
         MessageBox.Show("Impossible de récupérer les messages");
         RaisePropertyChanged("LastError");
     };
     SocialService.LastResultChanged += (s, e) => RaisePropertyChanged("LatestMessages");
 }
示例#15
0
        protected override void OnEventFired(object source, ButtonClickedEventArgs args)
        {
            //Do nothing, it's not valid.
            if (String.IsNullOrWhiteSpace(FriendInputText.Text))
            {
                return;
            }

            //Disable the add button temporarily.
            AddFriendButton.IsInteractable = false;

            //Try adding them
            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                try
                {
                    var responseModel = await SocialService.TryAddFriendAsync(FriendInputText.Text);

                    if (responseModel.isSuccessful)
                    {
                        if (Logger.IsInfoEnabled)
                        {
                            Logger.Info($"Friend add successful. EntityId: {responseModel.Result.NewFriendEntityGuid}");
                        }

                        //Just publish us gaining a new friend.
                        FriendAddedPublisher.PublishEvent(this, new CharacterFriendAddedEventArgs(responseModel.Result.NewFriendEntityGuid));
                    }
                    else
                    if (Logger.IsWarnEnabled)
                    {
                        Logger.Warn($"Friend add failed. Result Code: {responseModel.ResultCode}");
                    }
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Friend add failed. Exception: {e.ToString()}");
                    }

                    throw;
                }
                finally
                {
                    //Close it either way, even if the add failed.
                    //Then renable it for future use.
                    FriendsAddModalWindow.SetElementActive(false);
                    AddFriendButton.IsInteractable = true;
                    FriendInputText.Text           = "";
                }
            });
        }
示例#16
0
 // ReSharper disable once UnusedMember.Local
 private void OnEnable()
 {
     instance          = this;
     _logText          = transform.GetComponentInChildren <Text>(true);
     _logText.fontSize = FONT_SIZE_I;
     _socialService    = new SocialService();
     _facebookService  = new FacebookService();
     _facebookService.EnqueueOperation <LoginForReadOperation>();
     _facebookService.EnqueueOperation <AppLinkRequestOperation>();
     _facebookService.EnqueueOperation <ListFriendsOperation>();
     _facebookService.OnClientConnect();
 }
示例#17
0
        /// <summary>
        /// Выводит найденый сервис или возвращает false в случае неудачи.
        /// </summary>
        /// <param name="ss">Эквивалентный строковый код.</param>
        /// <param name="value">Социальный сервис.</param>
        /// <returns>True, если поиск был успешен, иначе false.</returns>
        public static bool TryFind(string ss, out SocialService value)
        {
            value = SocialService.AnyOther;

            if (All.ContainsValue(ss))
            {
                value = All.Where(x => x.Value == ss).Select(x => x.Key).FirstOrDefault();
                return(true);
            }

            return(false);
        }
示例#18
0
    private void Initialize()
    {
        if (userService == null)
        {
            userService = serviceAPI.BuildUserService();
        }

        if (socialService == null)
        {
            socialService = serviceAPI.BuildSocialService();
        }
    }
示例#19
0
        /// <summary>
        /// Статический инициализатор класса <see cref="SocialServices"/>.
        /// </summary>
        static SocialServices()
        {
            All = new Dictionary <SocialService, string>();

            foreach (string name in Enum.GetNames <SocialService>())
            {
                SocialService ss = Enum.Parse <SocialService>(name, true);
                if (TryFind(ss, out string value))
                {
                    All.Add(ss, value);
                }
            }
        }
示例#20
0
        public SocialController(ServiceFacade.Controller context,
                                LanguageService languageService,
                                SocialManagementService socialManagementService,
                                SocialService socialService) : base(context)
        {
            _languageService = languageService
                               ?? throw new ArgumentNullException(nameof(languageService));
            _socialManagementService = socialManagementService
                                       ?? throw new ArgumentNullException(nameof(socialManagementService));
            _socialService = socialService
                             ?? throw new ArgumentNullException(nameof(socialService));

            PageTitle = "Social";
        }
示例#21
0
            internal static void Start(object obj)
            {
                _queue = new ConcurrentWorkQueue <Action>(action => action());

                Game.Init();
                RunService.Init();
                SocialService.Init();
                HttpService.Init();
                ScriptService.Init();
                //AnalyticsService.Init();

                _resetter.Set();
                var stopwatch        = Stopwatch.StartNew();
                var physicsStopwatch = Stopwatch.StartNew();

                while (!CancelTokenSource.IsCancellationRequested)
                {
                    var step = stopwatch.Elapsed.TotalSeconds;
                    stopwatch.Restart();

                    // User Input
                    InputService.Step();

                    Game.FocusedCamera?.UpdateCamera(step);

                    // Network Replication
                    Game.NetworkServer?.Update(step);
                    Game.NetworkClient?.Update(step);

                    // wait() resume
                    ScriptService.ResumeWaitingScripts();

                    // Stepped
                    RunService.Update(step);
                    _queue.Work();

                    // Physics
                    var physicsStep = (float)physicsStopwatch.Elapsed.TotalSeconds;
                    foreach (var world in Game.Worlds)
                    {
                        world.Key.Physics?.Step(physicsStep);
                    }
                    physicsStopwatch.Restart();

                    // Heartbeat
                    RunService.Service.Heartbeat.Fire(step);
                }
            }
示例#22
0
 public static void GetFacebookProfilesFromIds(IList<String> facebookIds, App42ApiResultCallback requestCallback)
 {
     try
     {
         App42ApiCallback _sCallback = new App42ApiCallback(requestCallback);
         if (mSocialService == null)
         {
             mSocialService = GlobalContext.SERVICE_API.BuildSocialService();
         }
         mSocialService.GetFacebookProfilesFromIds(facebookIds, _sCallback);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
示例#23
0
 public static void GetFacebookFriendsFromLinkUser(App42ApiResultCallback callBack)
 {
     try
     {
         App42ApiCallback _sCallback = new App42ApiCallback(callBack);
         if (mSocialService == null)
         {
             mSocialService = GlobalContext.SERVICE_API.BuildSocialService();
         }
         mSocialService.GetFacebookFriendsFromAccessToken(GlobalContext.AccessToken, _sCallback);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
 public HomeController(ILogger <HomeController> logger,
                       ServiceFacade.Controller context,
                       ActivityService activityService,
                       AvatarService avatarService,
                       CarouselService carouselService,
                       DailyLiteracyTipService dailyLiteracyTipService,
                       DashboardContentService dashboardContentService,
                       EmailManagementService emailManagementService,
                       EmailReminderService emailReminderService,
                       EventService eventService,
                       LanguageService languageService,
                       PerformerSchedulingService performerSchedulingService,
                       SiteService siteService,
                       SocialService socialService,
                       UserService userService,
                       VendorCodeService vendorCodeService)
     : base(context)
 {
     _logger          = logger ?? throw new ArgumentNullException(nameof(logger));
     _activityService = activityService
                        ?? throw new ArgumentNullException(nameof(activityService));
     _avatarService = avatarService
                      ?? throw new ArgumentNullException(nameof(avatarService));
     _carouselService = carouselService
                        ?? throw new ArgumentNullException(nameof(carouselService));
     _dailyLiteracyTipService = dailyLiteracyTipService
                                ?? throw new ArgumentNullException(nameof(dailyLiteracyTipService));
     _dashboardContentService = dashboardContentService
                                ?? throw new ArgumentNullException(nameof(dashboardContentService));
     _emailManagementService = emailManagementService
                               ?? throw new ArgumentNullException(nameof(emailManagementService));
     _emailReminderService = emailReminderService
                             ?? throw new ArgumentNullException(nameof(emailReminderService));
     _eventService = eventService
                     ?? throw new ArgumentNullException(nameof(eventService));
     _languageService = languageService
                        ?? throw new ArgumentNullException(nameof(languageService));
     _performerSchedulingService = performerSchedulingService
                                   ?? throw new ArgumentNullException(nameof(performerSchedulingService));
     _siteService   = siteService ?? throw new ArgumentNullException(nameof(siteService));
     _socialService = socialService
                      ?? throw new ArgumentNullException(nameof(socialService));
     _userService       = userService ?? throw new ArgumentNullException(nameof(userService));
     _vendorCodeService = vendorCodeService
                          ?? throw new ArgumentNullException(nameof(vendorCodeService));
 }
示例#25
0
        protected override void OnEventFired(object source, EventArgs args)
        {
            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                CharacterFriendListResponseModel friendsResponse = await SocialService.GetCharacterListAsync();

                foreach (int characterId in friendsResponse.CharacterFriendsId)
                {
                    NetworkEntityGuid entityGuid = NetworkEntityGuidBuilder.New()
                                                   .WithType(EntityType.Player)
                                                   .WithId(characterId)
                                                   .Build();

                    FriendAddedPublisher.PublishEvent(this, new CharacterFriendAddedEventArgs(entityGuid));
                }
            });
        }
示例#26
0
    public void RequestInviteApp(string message)
    {
        SocialType type = SocialType.Facebook;

        Puppet.Service.SocialService.AppRequest(type, message, null, null, (status, requestIds) =>
        {
            if (status)
            {
                Puppet.API.Client.APIGeneric.SaveRequestFB(SocialService.GetSocialNetwork(type).UserId, requestIds, (saveStatus, saveMessage) =>
                {
                    string responseMessage = saveStatus ? "Bạn đã gửi lời mới thành công." : saveMessage;
                    DialogService.Instance.ShowDialog(new DialogMessage("Gửi lời mời.", responseMessage, null));
                });
            }
            else
            {
                DialogService.Instance.ShowDialog(new DialogMessage("Gửi lời mời.", "Không thể gửi lời mới cho bạn bè", null));
            }
        });
    }
示例#27
0
        /// <summary>
        /// Выводит найденый сервис или возвращает false в случае неудачи.
        /// </summary>
        /// <param name="socialService">Социальный сервис.</param>
        /// <param name="value">Эквивалентный строковый код.</param>
        /// <returns>True, если поиск был успешен, иначе false.</returns>
        public static bool TryFind(SocialService socialService, out string value)
        {
            value = string.Empty;
            string?name = Enum.GetName(socialService);

            if (name is null)
            {
                return(false);
            }

            PropertyInfo?property = typeof(SocialServices).GetProperty(name, BindingFlags.Public | BindingFlags.Static);

            if (property is null)
            {
                return(false);
            }

            value = property.GetValue(null) as string ?? value;
            return(true);
        }
示例#28
0
        public SocialViewModel(IStationInfo stationInfo)
        {
            ChatRoomId                  = stationInfo.Id;
            PageTitle                   = stationInfo.Name;
            this.MessageSent           += MessageSentHandler;
            SocialService               = new SocialService();
            SocialService.ErrorOccured += (s, e) =>
            {
                MessageBox.Show(AppResources.Error_NoMessage);
                RaisePropertyChanged("LastError");

                ShowProgress = Visibility.Collapsed;
                RaisePropertyChanged("ShowProgress");
            };
            SocialService.LastResultChanged += (s, e) =>
            {
                RaisePropertyChanged("LatestMessages");
                ShowProgress = Visibility.Collapsed;
                RaisePropertyChanged("ShowProgress");
                RaiseMessageRefreshed();
            };
        }
示例#29
0
        public SocialViewModel(IStationInfo stationInfo)
        {
            ChatRoomId = stationInfo.Id;
            PageTitle = stationInfo.Name;
            this.MessageSent += MessageSentHandler;
            SocialService = new SocialService();
            SocialService.ErrorOccured += (s, e) =>
            {
                MessageBox.Show(AppResources.Error_NoMessage);
                RaisePropertyChanged("LastError");

                ShowProgress = Visibility.Collapsed;
                RaisePropertyChanged("ShowProgress");
            };
            SocialService.LastResultChanged += (s, e) =>
                {
                    RaisePropertyChanged("LatestMessages");
                    ShowProgress = Visibility.Collapsed;
                    RaisePropertyChanged("ShowProgress");
                    RaiseMessageRefreshed();
                };
        }
示例#30
0
        protected override void OnEventFired(object source, EventArgs args)
        {
            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                var guildStatus = await SocialService.GetCharacterMembershipGuildStatus(PlayerDetails.LocalPlayerGuid.EntityId);

                if (Logger.IsInfoEnabled)
                {
                    Logger.Info($"Local Player GuildStatus: {guildStatus.ResultCode} Id: {guildStatus?.Result?.GuildId}");
                }

                if (guildStatus.isSuccessful)
                {
                    //TODO: Don't do it this way. It's useless
                    //Add the guild status change.
                    GuildMembershipMappable.AddObject(PlayerDetails.LocalPlayerGuid, guildStatus.Result);
                }

                //Kinda hacky but we spoof a guild status change here
                await SocialClient.ReceiveGuildStatusChangedEventAsync(new GuildStatusChangedEventModel(PlayerDetails.LocalPlayerGuid, guildStatus.isSuccessful ? guildStatus.Result.GuildId : 0));
            });
        }
    public static SocialService GetSocialService()
    {
        SocialService socialService = App42API.BuildSocialService();

        return(socialService);
    }
    // Use this for initialization
    void Start()
    {
        mHighScore = PlayerPrefs.GetInt("highscore", 0);

        // Build Shephertz services
        socialService = App42API.BuildSocialService();
        scoreBoardService = App42API.BuildScoreBoardService();

        DontDestroyOnLoad(this.gameObject);
    }
示例#33
0
 public void LoginFacebook()
 {
     SocialService.SocialLogin(SocialType.Facebook);
 }
示例#34
0
 /// <summary>
 /// Выводит найденый сервис.
 /// </summary>
 /// <param name="socialService">Социальный сервис.</param>
 /// <returns>Эквивалентный строковый код.</returns>
 public static string Find(SocialService socialService) => TryFind(socialService, out string ss) ? ss : throw new FormatException();
示例#35
0
 public SocialHub(SocialService socialService, IdentityService identityService)
 {
     this.socialService   = socialService;
     this.identityService = identityService;
 }
示例#36
0
 public static void ShareStatus(String message, App42ApiResultCallback requestCallback)
 {
     try
     {
         App42ApiCallback _sCallback = new App42ApiCallback(requestCallback);
         if (mSocialService == null)
         {
             mSocialService = GlobalContext.SERVICE_API.BuildSocialService();
         }
         mSocialService.UpdateFacebookStatus(GlobalContext.g_UserProfile.UserID,message, _sCallback);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
示例#37
0
 public static void LinkUserFacebookAccount(App42ApiResultCallback callBack)
 {
     App42ApiCallback _sCallback = new App42ApiCallback(callBack);
     if (mSocialService == null)
     {
         mSocialService = GlobalContext.SERVICE_API.BuildSocialService();
     }
     mSocialService.LinkUserFacebookAccount(GlobalContext.g_UserProfile.UserID, GlobalContext.AccessToken, _sCallback);
 }
示例#38
0
    void OnGUI()
    {
        if (Time.time % 2 < 1) {
            success = callBack.getResult();
        }

        // For Setting Up ResponseBox.
        GUI.TextArea(new Rect(10,5,1300,175), success);

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(50, 200, 200, 30), "LinkUserFacebookAccount"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.LinkUserFacebookAccount(userName,fbAccessToken,appId,appSecret,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(260, 200, 200, 30), "LinkUserFacebookAccountAcsTkn"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.LinkUserFacebookAccount(userName,fbAccessToken,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(470, 200, 200, 30), "UpdateFacebookStatus"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.UpdateFacebookStatus(userName,status,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(680, 200, 200, 30), "LinkUserTwitterAccount"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.LinkUserTwitterAccount(userName,accessToken,accessTokenSecret,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(890, 200, 200, 30), "LinkUserTwitterAccount"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.LinkUserTwitterAccount(userName,accessToken,accessTokenSecret,consumerKey,consumerSecret,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(50, 250, 200, 30), "UpdateTwitterStatus"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.UpdateTwitterStatus(userName,status,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(260, 250, 200, 30), "LinkUserLinkedInAccount"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.LinkUserLinkedInAccount(userName,linkedinAccessToken,linkedinAccessTokenSecret,linkedinApiKey,linkedinSecretKey,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(470, 250, 200, 30), "LinkUserLinkedInAccount"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.LinkUserLinkedInAccount(userName,accessToken,accessTokenSecret,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(680, 250, 200, 30), "UpdateLinkedInStatus"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.UpdateLinkedInStatus(userName,status,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(890, 250, 200, 30), "UpdateSocialStatusForAll"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.UpdateSocialStatusForAll(userName,status,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(50, 300, 200, 30), "GetFacebookFriendsFromLinkUser"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.GetFacebookFriendsFromLinkUser(userName,callBack);
            }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(260, 300, 200, 30), "GetFacebookFriendsFromAccessToken"))
            {
                socialService = sp.BuildSocialService(); // Initializing Social Service.
                socialService.GetFacebookFriendsFromAccessToken(accessToken,callBack);
            }
    }
示例#39
0
        protected override async Task OnMessageRecieved(IHubConnectionMessageContext <IRemoteSocialHubClient> context, GuildMemberInviteRequestModel payload)
        {
            var nameQueryResponseTask = NameQueryService.RetrievePlayerGuidAsync(payload.MemberToInvite);

            //First we need to check if they're in a guild.
            //We don't really need to handle the response for this, since it should never really happen.
            var guildStatus = await SocialService.GetCharacterMembershipGuildStatus(context.CallerGuid.EntityId);

            if (!guildStatus.isSuccessful)
            {
                if (Logger.IsEnabled(LogLevel.Warning))
                {
                    Logger.LogWarning($"User: {context.CallerGuid} attempted to Invite: {payload.MemberToInvite} to a guild but was not apart of a guild.");
                }

                return;
            }

            //Now we should know what guild the caller is in due to the query.
            //Now we need to do a reverse namequery to get the guid of who they're attempting to invite.
            var nameQueryResponse = await nameQueryResponseTask;

            //If it's not successful, assume the user doesn't exist.
            if (!nameQueryResponse.isSuccessful)
            {
                await SendGuildInviteResponse(context, GuildMemberInviteResponseCode.PlayerNotFound, NetworkEntityGuid.Empty);

                return;
            }

            //Now check if the user is already guilded
            //If they are we should indicate that to the client.
            if (await CheckIfGuilded(nameQueryResponse.Result))
            {
                await SendGuildInviteResponse(context, GuildMemberInviteResponseCode.PlayerAlreadyInGuild, nameQueryResponse.Result);

                return;
            }

            //Ok, the reverse name query was successful. Check if there is a pending invite.
            //TODO: Right now we rely on local state to indicate if there is a pending invite. We need to NOT do that because it won't work when we scale out.
            ProjectVersionStage.AssertBeta();

            //TODO: There is a race condition if multiple invites are sent at the same time, should we care??
            //If they have a pending invite.
            if (PendingInviteData.ContainsKey(nameQueryResponse.Result))
            {
                //If NOT expired then we need to say they're currently pending an invite
                if (!PendingInviteData[nameQueryResponse.Result].isInviteExpired())
                {
                    await SendGuildInviteResponse(context, GuildMemberInviteResponseCode.PlayerAlreadyHasPendingInvite, nameQueryResponse.Result);

                    return;
                }
                else
                {
                    //The invite is EXPIRED so let's added a new one.
                    PendingInviteData.ReplaceObject(nameQueryResponse.Result, GeneratePendingInviteData(context.CallerGuid, guildStatus.Result.GuildId));
                }
            }
            else
            {
                PendingInviteData.AddObject(nameQueryResponse.Result, GeneratePendingInviteData(context.CallerGuid, guildStatus.Result.GuildId));
            }
            //TODO: There is currently no handling to indicate that they are online.

            //Now they have a valid pending invite, so let's address the client
            //that needs to recieve the guild invite.
            IRemoteSocialHubClient playerClient = context.Clients.RetrievePlayerClient(nameQueryResponse.Result);

            //Indicate the player has been invited.
            await SendGuildInviteResponse(context, GuildMemberInviteResponseCode.Success, nameQueryResponse.Result);

            //Now tell the remote/target player they're being invited to a guild.
            await playerClient.ReceiveGuildInviteEventAsync(new GuildMemberInviteEventModel(guildStatus.Result.GuildId, context.CallerGuid));
        }
示例#40
0
    void OnGUI()
    {
        if (Time.time % 2 < 1)
        {
            success = callBack.getResult();
        }

        // For Setting Up ResponseBox.
        GUI.TextArea(new Rect(10, 5, 1300, 175), success);


        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(50, 200, 200, 30), "LinkUserFacebookAccount"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.LinkUserFacebookAccount(userName, fbAccessToken, appId, appSecret, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(260, 200, 200, 30), "LinkUserFacebookAccountAcsTkn"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.LinkUserFacebookAccount(userName, fbAccessToken, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(470, 200, 200, 30), "UpdateFacebookStatus"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.UpdateFacebookStatus(userName, status, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(680, 200, 200, 30), "LinkUserTwitterAccount"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.LinkUserTwitterAccount(userName, accessToken, accessTokenSecret, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(890, 200, 200, 30), "LinkUserTwitterAccount"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.LinkUserTwitterAccount(userName, accessToken, accessTokenSecret, consumerKey, consumerSecret, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(50, 250, 200, 30), "UpdateTwitterStatus"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.UpdateTwitterStatus(userName, status, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(260, 250, 200, 30), "LinkUserLinkedInAccount"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.LinkUserLinkedInAccount(userName, linkedinAccessToken, linkedinAccessTokenSecret, linkedinApiKey, linkedinSecretKey, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(470, 250, 200, 30), "LinkUserLinkedInAccount"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.LinkUserLinkedInAccount(userName, accessToken, accessTokenSecret, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(680, 250, 200, 30), "UpdateLinkedInStatus"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.UpdateLinkedInStatus(userName, status, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(890, 250, 200, 30), "UpdateSocialStatusForAll"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.UpdateSocialStatusForAll(userName, status, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(50, 300, 200, 30), "GetFacebookFriendsFromLinkUser"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.GetFacebookFriendsFromLinkUser(userName, callBack);
        }

        //=======================================SOCIAL_SERVICE=======================================

        if (GUI.Button(new Rect(260, 300, 200, 30), "GetFacebookFriendsFromAccessToken"))
        {
            socialService = sp.BuildSocialService();                     // Initializing Social Service.
            socialService.GetFacebookFriendsFromAccessToken(accessToken, callBack);
        }
    }