ServerNetworkConnections.ClientConnectionListener.StartAccepting C# (CSharp) Method

StartAccepting() public method

Method to make the ClientConnectionListener start listening.
public StartAccepting ( ) : void
return void
        public void StartAccepting()
        {
            if (!IsAccepting)
            {
                listener.Start();
                thr = new Thread(Go);
                thr.Priority = ThreadPriority.Highest;
                thr.IsBackground = true;
                thr.Start();

                if(PropertyChanged != null)
                    PropertyChanged(this, new PropertyChangedEventArgs("IsAccepting"));
            }
        }

Usage Example

Example #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // create model
            UserLocations = new ObservableCollection<UserLocation>();
            UserList = new ClientConnectionList();
            Actions = new ObservableCollection<ActionMessage>();
            Listener = new ClientConnectionListener(50000, new XmlMessageParser()); // add parser
            Listener.InitialConnectionSuccess += OnInitialConnectionSuccess;
            Listener.InitialConnectionFailed += OnInitialConnectionFailed;
            Listener.ConnectionFailed += OnConnectionFailed;
            Listener.MessageReceived += OnMessageReceived;
            Listener.MessageFailed += OnMessageFailed;

            // create view model
            MainWindowViewModel = new MainWindowViewModel();
            MainWindowViewModel.UserList = UserList;
            MainWindowViewModel.Actions = Actions;
            MainWindowViewModel.UserLocations = UserLocations;

            // create view
            MainWindow = new MainWindow();
            MainWindow.DataContext = MainWindowViewModel;
            MainWindow.Show();

            // start listening
            Listener.StartAccepting();

            UpdaterTask task = new UpdaterTask(
                Dispatcher,
                TaskHandler.Background,
                UserList,
                UserLocations);

            task.ProgressChanged += TaskProgressReport;
            task.BeginExecute();
        }