Example #1
0
        //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);
        }
Example #2
0
        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);
        }
Example #3
0
        //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);
        }
Example #4
0
 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));
 }
Example #5
0
 public VoiceState(SocketVoiceChannel voiceChannel, Model model)
     : this(voiceChannel, model.SessionId, model.SelfMute, model.SelfDeaf, model.Suppress)
 {
 }
Example #6
0
 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));
 }