diff --git a/Server/Models/Information.cs b/Server/Models/Information.cs index eb2b690..1764312 100644 --- a/Server/Models/Information.cs +++ b/Server/Models/Information.cs @@ -17,6 +17,6 @@ namespace Server.Models } } - public int ClientsConnected{ get; set; } + public int ClientsConnected{ get { return ServerCommunication.INSTANCE.ClientsConnected; } } } } \ No newline at end of file diff --git a/Server/Models/ServerCommunication.cs b/Server/Models/ServerCommunication.cs index 8869581..4dcf07a 100644 --- a/Server/Models/ServerCommunication.cs +++ b/Server/Models/ServerCommunication.cs @@ -14,6 +14,7 @@ namespace Server.Models private TcpListener listener; private List serverClients; public bool Started = false; + public int ClientsConnected { get { return serverClients.Count; } } /// /// use a padlock object to make sure the singleton is thread-safe diff --git a/Server/ViewModels/MainViewModel.cs b/Server/ViewModels/MainViewModel.cs index bd7d0a4..0ff5359 100644 --- a/Server/ViewModels/MainViewModel.cs +++ b/Server/ViewModels/MainViewModel.cs @@ -22,10 +22,10 @@ namespace Server.ViewModels public MainViewModel(MainWindow mainWindow) { + serverCommunication = ServerCommunication.INSTANCE; this.mainWindow = mainWindow; Debug.WriteLine("init mainviewmodel"); InformationModel = new Information(); - InformationModel.ClientsConnected = 0; InformationModel.CanStartServer = true; InformationModel.ServerOnline = false; //BitmapImage onlineImg = new BitmapImage(new Uri(@"/img/online.png",UriKind.Relative)); @@ -34,15 +34,9 @@ namespace Server.ViewModels this.ServerStartCommand = new RelayCommand(() => { Debug.WriteLine("connect button clicked"); - if (serverCommunication == null) - { - Debug.WriteLine("making new server communication"); - serverCommunication = ServerCommunication.INSTANCE; - } + if (!serverCommunication.Started) { - - serverCommunication.Start(); InformationModel.ServerOnline = true; InformationModel.CanStartServer = false;