internal void AddUser(UserState newUserState) { if (!AllUsers.ContainsKey(newUserState.session)) { AllUsers[newUserState.session] = newUserState; AudioDecodingBuffer buffer = new AudioDecodingBuffer(_codec); _audioDecodingBuffers.Add(newUserState.session, buffer); EventProcessor.Instance.QueueEvent(() => { // We also create a new audio player for each user MumbleAudioPlayer newPlayer = _audioPlayerCreator(); _mumbleAudioPlayers.Add(newUserState.session, newPlayer); newPlayer.Initialize(this, newUserState.session); }); } else { // Copy over the things that have changed //TODO we should be doing with with a proto merge in MumbleTCPConnection, //but I don't know how to identify object it needs to be merged with before it's been deserialized if (!string.IsNullOrEmpty(newUserState.name)) { AllUsers[newUserState.session].name = newUserState.name; } AllUsers[newUserState.session].channel_id = newUserState.channel_id; } }
private void AddDecodingBuffer(UserState userState) { // Make sure we don't double add if (_audioDecodingBuffers.ContainsKey(userState.Session)) { return; } //Debug.Log("Adding : " + userState.Name + " #" + userState.Session); //Debug.Log("Adding decoder session #" + userState.Session); DecodedAudioBuffer buffer = _decodingBufferPool.GetDecodingBuffer(); buffer.Init(userState.Name, userState.Session); _audioDecodingBuffers.Add(userState.Session, buffer); EventProcessor.Instance.QueueEvent(() => { //Debug.Log("Adding audioPlayer session #" + userState.Session); // We also create a new audio player for the user MumbleAudioPlayer newPlayer = _audioPlayerCreator(userState.Name, userState.Session); _mumbleAudioPlayers.Add(userState.Session, newPlayer); newPlayer.Initialize(this, userState.Session); }); if (OnNewDecodeBufferThreaded != null) { OnNewDecodeBufferThreaded(userState.Session); } }
internal void AddUser(UserState newUserState) { if (!AllUsers.ContainsKey(newUserState.session)) { Debug.Log("Adding user: "******"New audio buffer with session: " + newUserState.session); AllUsers[newUserState.session] = newUserState; AudioDecodingBuffer buffer = new AudioDecodingBuffer(_codec); _audioDecodingBuffers.Add(newUserState.session, buffer); EventProcessor.Instance.QueueEvent(() => { // We also create a new audio player for each user MumbleAudioPlayer newPlayer = _audioPlayerCreator(); _mumbleAudioPlayers.Add(newUserState.session, newPlayer); MumbleUserNameBuffer = newUserState.name; newPlayer.Initialize(this, newUserState.session, MumbleUserNameBuffer); }); } else { // Copy over the things that have changed //TODO we should be doing with with a proto merge in MumbleTCPConnection, //but I don't know how to identify object it needs to be merged with before it's been deserialized if (!string.IsNullOrEmpty(newUserState.name)) { AllUsers[newUserState.session].name = newUserState.name; } // If this is us, and it's signaling that we've changed channels, notify the delegate on the main thread if (newUserState.session == OurUserState.session && OurUserState.channel_id != newUserState.channel_id) { AllUsers[newUserState.session].channel_id = newUserState.channel_id; EventProcessor.Instance.QueueEvent(() => { if (OnChannelChanged != null) { OnChannelChanged(Channels[newUserState.channel_id]); } }); } else { AllUsers[newUserState.session].channel_id = newUserState.channel_id; } } }