/// <summary>
        /// ServerSync message is sent by the server when it has authenticated the user and finished synchronizing the server state.
        /// </summary>
        /// <param name="serverSync"></param>
        public virtual void ServerSync(ServerSync serverSync)
        {
            if (LocalUser != null)
            {
                throw new InvalidOperationException("Second ServerSync Received");
            }

            if (!serverSync.ShouldSerializeSession())
            {
                throw new InvalidOperationException($"{nameof(ServerSync)} must provide a {nameof(serverSync.Session)}.");
            }

            //Get the local user
            LocalUser = UserDictionary[serverSync.Session];

            //TODO: handle the serverSync.WelcomeText, serverSync.Permissions, serverSync.MaxBandwidth

            if (Connection.VoiceSupportEnabled)
            {
                _encodingBuffer         = new AudioEncodingBuffer(_audioSampleRate, _audioSampleBits, _audioSampleChannels, _audioFrameSize);
                _encodingBuffer.Bitrate = _audioBitrate;
                _encodingThread.Start();
            }

            ReceivedServerSync = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Initial connection to the server
        /// </summary>
        /// <param name="serverSync"></param>
        public virtual void ServerSync(ServerSync serverSync)
        {
            if (LocalUser != null)
            {
                throw new InvalidOperationException("Second ServerSync Received");
            }

            //Get the local user
            LocalUser = UserDictionary[serverSync.Session];

            _encodingBuffer = new AudioEncodingBuffer();
            _encodingThread.Start();

            ReceivedServerSync = true;
        }