Пример #1
0
        public async Task ClosePlanetChatChannel(ChannelWindowComponent window)
        {
            ClientPlanetChatChannel channel = window.Channel;

            OpenPlanetChatWindows.Remove(window);

            // If there are no longer any windows open for the channel, leave
            if (!OpenPlanetChatWindows.Any(x => x.Channel.Id == channel.Id))
            {
                // Leaves channel via signalr
                await signalRManager.hubConnection.SendAsync("LeaveChannel", channel.Id);

                // Remove from list
                OpenPlanetChatChannels.Remove(channel.Id);

                Console.WriteLine($"Left SignalR group for channel {channel.Id}");
            }
        }
Пример #2
0
        public async Task NotifyUpdateChannel(ClientPlanetChatChannel channel)
        {
            if (_channel_ids == null)
            {
                await LoadChannelsAsync();
            }

            // Set in cache
            ClientCache.Channels[channel.Id] = channel;

            // Re-order channels
            List <ClientPlanetChatChannel> channels = new();

            foreach (var id in _channel_ids)
            {
                channels.Add(ClientCache.Channels[id]);
            }

            _channel_ids = channels.OrderBy(x => x.Position).Select(x => x.Id).ToList();
        }
Пример #3
0
        public async Task OpenPlanetChatChannel(ChannelWindowComponent window)
        {
            ClientPlanetChatChannel channel = window.Channel;

            if (!OpenPlanetChatChannels.ContainsKey(channel.Id))
            {
                ClientPlanet planet = await channel.GetPlanetAsync();

                // Ensure planet is opened
                await OpenPlanet(planet);

                // Joins channel via SignalR
                await signalRManager.hubConnection.SendAsync("JoinChannel", channel.Id, ClientUserManager.UserSecretToken);

                // Add to open channel list
                OpenPlanetChatChannels.Add(channel.Id, window.Channel);

                Console.WriteLine($"Joined SignalR group for channel {channel.Id}");
            }

            OpenPlanetChatWindows.Add(window);
        }
Пример #4
0
        /// <summary>
        /// Returns the primary channel of the planet
        /// </summary>
        public async Task <ClientPlanetChatChannel> GetPrimaryChannelAsync(IMapper mapper)
        {
            string json = await ClientUserManager.Http.GetStringAsync($"Planet/GetPrimaryChannel?planet_id={Id}" +
                                                                      $"&userid={ClientUserManager.User.Id}" +
                                                                      $"&token={ClientUserManager.UserSecretToken}");

            TaskResult <PlanetChatChannel> channelResult = JsonConvert.DeserializeObject <TaskResult <PlanetChatChannel> >(json);

            if (channelResult == null)
            {
                Console.WriteLine($"Failed to retrieve primary channel for planet {Id}.");
                return(null);
            }

            if (!channelResult.Success)
            {
                Console.WriteLine($"Failed to retrieve primary channel for planet {Id}: {channelResult.Message}");
            }

            // Map to new
            ClientPlanetChatChannel channel = mapper.Map <ClientPlanetChatChannel>(channelResult.Data);

            return(channel);
        }
Пример #5
0
 public ChatChannelWindow(int index, ClientPlanetChatChannel channel) : base(index)
 {
     this.Channel = channel;
 }
Пример #6
0
        public void NotifyDeleteChannel(ClientPlanetChatChannel channel)
        {
            _channel_ids.Remove(channel.Id);

            ClientCache.Channels.Remove(channel.Id, out _);
        }