//Voice States internal SocketVoiceState AddOrUpdateVoiceState(ClientState state, VoiceStateModel model) { var voiceChannel = state.GetChannel(model.ChannelId.Value) as SocketVoiceChannel; var voiceState = SocketVoiceState.Create(voiceChannel, model); _voiceStates[model.UserId] = voiceState; return(voiceState); }
public VoiceState AddOrUpdateVoiceState(VoiceStateModel model, DataStore dataStore, ConcurrentDictionary <ulong, VoiceState> voiceStates = null) { var voiceChannel = dataStore.GetChannel(model.ChannelId.Value) as SocketVoiceChannel; var voiceState = new VoiceState(voiceChannel, model); (voiceStates ?? _voiceStates)[model.UserId] = voiceState; return(voiceState); }
//Voice States internal async Task <SocketVoiceState> AddOrUpdateVoiceStateAsync(ClientState state, VoiceStateModel model) { var voiceChannel = state.GetChannel(model.ChannelId.Value) as SocketVoiceChannel; var before = GetVoiceState(model.UserId) ?? SocketVoiceState.Default; var after = SocketVoiceState.Create(voiceChannel, model); _voiceStates[model.UserId] = after; if (_audioClient != null && before.VoiceChannel?.Id != after.VoiceChannel?.Id) { if (model.UserId == CurrentUser.Id) { if (after.VoiceChannel != null && _audioClient.ChannelId != after.VoiceChannel?.Id) { _audioClient.ChannelId = after.VoiceChannel.Id; await RepopulateAudioStreamsAsync().ConfigureAwait(false); } } else { await _audioClient.RemoveInputStreamAsync(model.UserId).ConfigureAwait(false); //User changed channels, end their stream if (CurrentUser.VoiceChannel != null && after.VoiceChannel?.Id == CurrentUser.VoiceChannel?.Id) { await _audioClient.CreateInputStreamAsync(model.UserId).ConfigureAwait(false); } } } return(after); }
internal static SocketVoiceState Create(SocketVoiceChannel voiceChannel, Model model) { return(new SocketVoiceState(voiceChannel, model.SessionId, model.SelfMute, model.SelfDeaf, model.Mute, model.Deaf, model.Suppress, model.SelfStream)); }
public VoiceState(SocketVoiceChannel voiceChannel, Model model) : this(voiceChannel, model.SessionId, model.SelfMute, model.SelfDeaf, model.Suppress) { }
internal static SocketVoiceState Create(SocketVoiceChannel voiceChannel, Model model) { return(new SocketVoiceState(voiceChannel, model.RequestToSpeakTimestamp.IsSpecified ? model.RequestToSpeakTimestamp.Value : null, model.SessionId, model.SelfMute, model.SelfDeaf, model.Mute, model.Deaf, model.Suppress, model.SelfStream, model.SelfVideo)); }