Esempio n. 1
0
        private void OnChatMessageRecieved(ChatChannelType channelType, [NotNull] IChannelTextMessage args)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }
            if (!Enum.IsDefined(typeof(ChatChannelType), channelType))
            {
                throw new InvalidEnumArgumentException(nameof(channelType), (int)channelType, typeof(ChatChannelType));
            }

            AccountId id          = args.Sender;
            int       characterId = int.Parse(id.Name);

            //TODO: We need to translate the guid to a name.
            NetworkEntityGuid guid = NetworkEntityGuidBuilder.New()
                                     .WithType(EntityType.Player)
                                     .WithId(characterId)
                                     .Build();

            if (NameQueryService.Exists(guid))
            {
                PublishTextData(channelType, args, guid, NameQueryService.Retrieve(guid));
            }
            else
            {
                UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
                {
                    string queryResponse = await NameQueryService.RetrieveAsync(guid)
                                           .ConfigureAwaitFalse();

                    PublishTextData(channelType, args, guid, queryResponse);
                });
            }
        }
Esempio n. 2
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));
                }
            });
        }
Esempio n. 3
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));
                }
            });
        }
Esempio n. 4
0
        public async Task <IActionResult> ReverseNameQuery([FromRoute(Name = "name")][JetBrains.Annotations.NotNull] string characterPlayerName)
        {
            if (string.IsNullOrWhiteSpace(characterPlayerName))
            {
                return(BuildFailedResponseModel(NameQueryResponseCode.UnknownIdError));
            }

            bool knownId = await CharacterRepository.ContainsAsync(characterPlayerName);

            //TODO: JSON Response
            if (!knownId)
            {
                return(BuildFailedResponseModel(NameQueryResponseCode.UnknownIdError));
            }

            //Else if it is a known id we should grab the name of the character
            CharacterEntryModel characterModel = await CharacterRepository.RetrieveAsync(characterPlayerName);

            return(BuildSuccessfulResponseModel(NetworkEntityGuidBuilder.New().WithType(EntityType.Player).WithId(characterModel.CharacterId).Build()));
        }