/// <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;
        }
Ejemplo n.º 2
0
        public void TestAddNewData()
        {
            var sync = new ServerSync();
            var json = "{\"Feedback\": [{ \"Id\": 3, \"Content\": \"色彩不够鲜明\", \"PersonId\": 4, \"AddTime\": \"2018-06-10 10:15\" },{ \"Id\": 4, \"Content\": \"色彩不够鲜明\", \"PersonId\": 4, \"AddTime\": \"2018-06-10 10:15\" },{ \"Id\": 5, \"Content\": \"色彩不够鲜明\", \"PersonId\": 4, \"AddTime\": \"2018-06-10 10:15\" },{ \"Id\": 6, \"Content\": \"色彩不够鲜明\", \"PersonId\": 4, \"AddTime\": \"2018-06-10 10:15\" }]}";

            sync.AddNewData(json);
        }
Ejemplo n.º 3
0
 internal void SetServerSync(ServerSync sync)
 {
     ServerSync   = sync;
     OurUserState = AllUsers[ServerSync.Session];
     // Now that we know who we are, we can determine which users need decoding buffers
     ReevaluateAllDecodingBuffers();
 }
Ejemplo n.º 4
0
        void SyncDB()
        {
            var categoryListCount = Manager.Getcategories().Count;

            if (categoryListCount < 1)
            {
                ServerSync.SyncCategories();
            }
        }
 public void StopServer()
 {
     if (_serverListener != null)
     {
         _stop = true;
         _serverSync.RequestStop();
         _serverSync = null;
         _serverListener.RequestStop();
         _serverListener = null;
     }
 }
Ejemplo n.º 6
0
        internal void SetServerSync(ServerSync sync)
        {
            ServerSync   = sync;
            OurUserState = AllUsers[ServerSync.Session];
            // Now that we know who we are, we can determine which users need decoding buffers
            ReevaluateAllDecodingBuffers();
            ConnectionSetupFinished = true;

            // Do the stuff we were waiting to do
            if (_pendingMute.HasValue)
            {
                SetSelfMute(_pendingMute.Value);
            }
            _pendingMute = null;
        }
Ejemplo n.º 7
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;
        }
        private void StartServer()
        {
            if (_serverListener == null)
            {
                StartExport();

                PopulateBanList();

                _serverListener = new UDPVoiceRouter(_connectedClients, _eventAggregator);
                var listenerThread = new Thread(_serverListener.Listen);
                listenerThread.Start();

                _serverSync = new ServerSync(_connectedClients, _bannedIps, _eventAggregator);
                var serverSyncThread = new Thread(_serverSync.StartListening);
                serverSyncThread.Start();
            }
        }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
0
 internal void SetServerSync(ServerSync sync)
 {
     ServerSync   = sync;
     OurUserState = AllUsers[ServerSync.session];
 }