Example #1
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));
                }
            });
        }
Example #2
0
        protected override void OnGuildStatusChanged(GuildStatusChangedEventModel changeArgs)
        {
            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                ResponseModel <NameQueryResponse, NameQueryResponseCode> nameQueryResponse = await NameQueryService.RetrieveGuildNameAsync(changeArgs.GuildId)
                                                                                             .ConfigureAwait(true);

                if (nameQueryResponse.isSuccessful)
                {
                    GuildNameText.Text = $"<{nameQueryResponse.Result.EntityName}>";
                }
                else
                {
                    GuildNameText.Text = $"<UNKNOWN-GUILDNAME>";
                }
            });
        }
Example #3
0
 public async Task ReceiveGuildStatusChangedEventAsync(GuildStatusChangedEventModel message)
 {
     OnGuildStatusChanged?.Invoke(this, GenericSocialEventArgs.Create(message));
 }
Example #4
0
        protected override void OnGuildStatusChanged(GuildStatusChangedEventModel changeArgs)
        {
            //TODO: This needs to be authorative
            ProjectVersionStage.AssertBeta();
            //If we're now guildless, we need to actually leave the guild chat channel
            //if we're in one.
            if (changeArgs.IsGuildless)
            {
                //TODO: Handle leaving guild channel
                return;
            }

            //We have a guild, let's join the guild channel now.
            UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() =>
            {
                try
                {
                    ResponseModel <VivoxChannelJoinResponse, VivoxLoginResponseCode> channelJoinResponse = await VivoxAutheAuthorizationService.JoinGuildChatAsync();

                    //TODO: Better handle failure.
                    if (!channelJoinResponse.isSuccessful)
                    {
                        if (Logger.IsErrorEnabled)
                        {
                            Logger.Error($"Failed to join Guild world channel. Reason: {channelJoinResponse.ResultCode}");
                        }

                        return;
                    }

                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info($"Recieved Vivox Channel URI: {channelJoinResponse.Result.ChannelURI}");
                    }

                    //TODO: Awaiting the ChatChannelSession may never complete. We should do a timeout.
                    //TODO: We should share these inputs as shared constants.
                    IChannelSession guildChannel = (await ChatChannelSession).GetChannelSession(new ChannelId(channelJoinResponse.Result.ChannelURI));

                    await guildChannel.ConnectionAsync(false, true, TransmitPolicy.Yes, channelJoinResponse.Result.AuthToken)
                    .ConfigureAwait(true);

                    if (Logger.IsInfoEnabled)
                    {
                        Logger.Info($"Joined Guild Chat");
                    }

                    //Broadcast that we've joined proximity chat.
                    ChannelJoinEventPublisher.PublishEvent(this, new ChatChannelJoinedEventArgs(ChatChannelType.Guild, new DefaultVivoxTextChannelSubscribableAdapter(guildChannel), new DefaultVivoxChatChannelSenderAdapter(guildChannel)));
                }
                catch (Exception e)
                {
                    if (Logger.IsErrorEnabled)
                    {
                        Logger.Error($"Failed to Initialize Guild chat. Reason: {e.Message}\n\nStack: {e.StackTrace}");
                    }

                    throw;
                }
            });
        }
Example #5
0
 protected override void OnGuildStatusChanged(GuildStatusChangedEventModel changeArgs)
 {
     //The guild tab should be accessible if we're not guildless.
     GuildListToggle.IsInteractable = !changeArgs.IsGuildless;
 }