public ServerViewModel() { //Setup commands StartServer = new RelayCommand(startServer); StopServer = new RelayCommand(storServer); //Setup event handlers AsynchronousClientListener.OnUserConnected((client) => Online = (Convert.ToInt32(Online) + 1).ToString()); AsynchronousClientListener.OnUserDisconnected((client) => Online = (Convert.ToInt32(Online) - 1).ToString()); ServerOffline = true; }
static UnitOfWork() { //Set up event data changed handler for tables Database.MessagesTableRepo.AddDataChangedHandler((sender, args) => OnMessagesTableChanged(sender, args)); Database.UsersTableRepo.AddDataChangedHandler((sender, args) => OnUsersTableChanged(sender, args)); Database.GroupsTableRepo.AddDataChangedHandler((sender, args) => OnGroupsTableChanged(sender, args)); //Add handlers on client connected and disconnected from the server AsynchronousClientListener.OnUserConnected(OnUserConnected); AsynchronousClientListener.OnUserDisconnected(OnUserDisconnected); //Add handler on new server command received e.g. new message CommandChain.OnNewClientCommand((sender, args) => OnClientCommand(sender, args)); }