Exemple #1
0
        void startServer()
        {
            Task.Run(() => AsynchronousClientListener.Start());
            var a = UnitOfWork.OnlineClients;

            ServerOnline  = true;
            ServerOffline = false;
        }
Exemple #2
0
        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;
        }
Exemple #3
0
        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));
        }
Exemple #4
0
 void storServer()
 {
     AsynchronousClientListener.Disconect(true);
     ServerOffline = true;
     ServerOnline  = false;
 }