public void EnsureChannelExists(KgsChannel channel) { if (!Channels.ContainsKey(channel.ChannelId)) { Channels.Add(channel.ChannelId, channel); } }
/// <summary> /// Unjoins the specified channel. If it wasn't joined, the events trigger anyway. /// </summary> /// <param name="channelId">Its ID.</param> public void UnjoinChannel(int channelId) { if (!Channels.ContainsKey(channelId)) { return; } KgsChannel channel = Channels[channelId]; channel.Joined = false; _kgsConnection.Events.RaiseUnjoin(channel); if (channel is KgsGameContainer) { KgsGameContainer container = channel as KgsGameContainer; GameContainers.Remove(container); } if (channel is KgsTrueGameChannel) { if (_joinedGames.ContainsKey(channel.ChannelId)) { _joinedGames.Remove(channel.ChannelId); } } SomethingChanged(); // Old: _kgsConnection.Events.RaiseChannelUnjoined(channel); }
public async Task GenericUnjoinAsync(KgsChannel channel) { await kgsConnection.MakeUnattendedRequestAsync("UNJOIN_REQUEST", new { ChannelId = channel.ChannelId }); }
public void Unjoined(KgsChannel channel) { if (channel.ChannelId == _channelId) { EndThis(); } }
private void Events_Unjoin(object sender, KgsChannel e) { //TODO (future work) Hack: This is a memory leak. This event will never be collected. Oh well. if (e.ChannelId == Challenge.ChannelId) { _vm.CloseSelf(); } }
public async void Joined(KgsChannel channel) { if (channel.ChannelId == _channelId) { EndThis(); await _connection.MakeUnattendedRequestAsync("CHALLENGE_SUBMIT", _simpleProposal); } }
/// <summary> /// Joins the specified channel. If it was already joined, events trigger anyway. /// This only affects <see cref="Channels"/>. /// </summary> /// <param name="channel">The channel.</param> private void JoinChannel(KgsChannel channel) { if (!Channels.ContainsKey(channel.ChannelId)) { Channels.Add(channel.ChannelId, channel); } channel.Joined = true; _kgsConnection.Events.RaiseChannelJoined(channel); SomethingChanged(); }
private async Task JoinChannelAsync(KgsChannel channel) { if (channel is KgsTrueGameChannel) { var trueChannel = channel as KgsTrueGameChannel; await Connections.Kgs.Commands.ObserveGameAsync(trueChannel.GameInfo); } else if (channel is KgsChallenge) { var challenge = channel as KgsChallenge; await Connections.Kgs.Commands.JoinAndSubmitSelfToChallengeAsync(challenge); } }
internal void RaiseUnjoin(KgsChannel channel) { Unjoin?.Invoke(this, channel); }
internal void RaiseChannelUnjoined(KgsChannel channel) { ChannelUnjoined?.Invoke(channel); }
private void Events_Unjoin(object sender, KgsChannel e) { this.Close(); }