added clients connected

This commit is contained in:
Sem van der Hoeven
2020-10-13 11:11:51 +02:00
parent 3dc641680d
commit 9bd45a5ba6
3 changed files with 4 additions and 9 deletions

View File

@@ -17,6 +17,6 @@ namespace Server.Models
} }
} }
public int ClientsConnected{ get; set; } public int ClientsConnected{ get { return ServerCommunication.INSTANCE.ClientsConnected; } }
} }
} }

View File

@@ -14,6 +14,7 @@ namespace Server.Models
private TcpListener listener; private TcpListener listener;
private List<ServerClient> serverClients; private List<ServerClient> serverClients;
public bool Started = false; public bool Started = false;
public int ClientsConnected { get { return serverClients.Count; } }
/// <summary> /// <summary>
/// use a padlock object to make sure the singleton is thread-safe /// use a padlock object to make sure the singleton is thread-safe

View File

@@ -22,10 +22,10 @@ namespace Server.ViewModels
public MainViewModel(MainWindow mainWindow) public MainViewModel(MainWindow mainWindow)
{ {
serverCommunication = ServerCommunication.INSTANCE;
this.mainWindow = mainWindow; this.mainWindow = mainWindow;
Debug.WriteLine("init mainviewmodel"); Debug.WriteLine("init mainviewmodel");
InformationModel = new Information(); InformationModel = new Information();
InformationModel.ClientsConnected = 0;
InformationModel.CanStartServer = true; InformationModel.CanStartServer = true;
InformationModel.ServerOnline = false; InformationModel.ServerOnline = false;
//BitmapImage onlineImg = new BitmapImage(new Uri(@"/img/online.png",UriKind.Relative)); //BitmapImage onlineImg = new BitmapImage(new Uri(@"/img/online.png",UriKind.Relative));
@@ -34,15 +34,9 @@ namespace Server.ViewModels
this.ServerStartCommand = new RelayCommand(() => this.ServerStartCommand = new RelayCommand(() =>
{ {
Debug.WriteLine("connect button clicked"); Debug.WriteLine("connect button clicked");
if (serverCommunication == null)
{
Debug.WriteLine("making new server communication");
serverCommunication = ServerCommunication.INSTANCE;
}
if (!serverCommunication.Started) if (!serverCommunication.Started)
{ {
serverCommunication.Start(); serverCommunication.Start();
InformationModel.ServerOnline = true; InformationModel.ServerOnline = true;
InformationModel.CanStartServer = false; InformationModel.CanStartServer = false;