Exemplo n.º 1
0
 public HomeViewModel(IRHDispatcher dispatcher, INavigation navigation)
 {
     _navigation   = navigation;
     _dispatcher   = dispatcher;
     LoadedCommand = new DelegateCommand(OnLoaded);
     HostCommand   = new DelegateCommand(OnHost);
     JoinCommand   = new DelegateCommand(OnJoin);
 }
Exemplo n.º 2
0
        public JoinViewModel(IRHDispatcher dispatcher, IServiceProvider serviceProvider, NavigationState navigationState, INavigation navigation)
        {
            _dispatcher      = dispatcher;
            _serviceProvider = serviceProvider;
            _navigationState = navigationState;
            _navigation      = navigation;

            LoadedCommand = new DelegateCommand(OnLoaded);
            StartCommand  = new DelegateCommand(OnStart);
            BackCommand   = new DelegateCommand(OnBack);
        }
Exemplo n.º 3
0
        public HostViewModel(IRHDispatcher dispatcher, IServiceProvider serviceProvider, NavigationState navigationState, INavigation navigation)
        {
            _dispatcher      = dispatcher;
            _serviceProvider = serviceProvider;
            _navigationState = navigationState;
            _navigation      = navigation;
            GetNewHostCode();
            ConnectEvent.Instance.Subscribe((obj) =>
            {
                switch (obj.Method)
                {
                case "ReceiveMessage":

                    break;
                }
            });
            LoadedCommand = new DelegateCommand(OnLoaded);
            StartCommand  = new DelegateCommand(OnStart);
            BackCommand   = new DelegateCommand(OnBack);
        }
Exemplo n.º 4
0
        public MeetingViewModel(IRHDispatcher dispatcher, IServiceProvider serviceProvider, NavigationState navigationState, INavigation navigation)
        {
            _dispatcher      = dispatcher;
            _serviceProvider = serviceProvider;
            _navigationState = navigationState;
            _navigation      = navigation;
            token            = ConnectEvent.Instance.Subscribe((c) =>
            {
                lock (lockobj) //Synchronous
                {
                    if (c.Parms.ContainsKey("HostCode") && c.Parms["HostCode"] != null && ((string)c.Parms["HostCode"]).ToUpper() == HostCode)
                    {
                        switch (c.Method)
                        {
                        case "ReceiveUpdate":
                            _dispatcher.Invoke(Dispatcher, () => {
                                var newUserNames = (List <string>)c.Parms["UserNames"];
                                foreach (var newUser in newUserNames)
                                {
                                    if (!UserNames.Contains(newUser))
                                    {
                                        UserNames.Add(newUser);
                                    }
                                }
                                var removeUsers = new List <string>();
                                foreach (var existUser in UserNames)
                                {
                                    if (!newUserNames.Contains(existUser))
                                    {
                                        removeUsers.Add(existUser);
                                    }
                                }
                                foreach (var user in removeUsers)
                                {
                                    UserNames.Remove(user);
                                }
                            });
                            break;

                        case "ReceiveUpdateRaiseHands":
                            if (c.Parms.ContainsKey("HostCode"))
                            {
                                _dispatcher.Invoke(Dispatcher, () => {
                                    var RaisedHands = (List <string>)c.Parms["RaisedHands"];
                                    RaisedNames.Clear();
                                    foreach (var name in RaisedHands)
                                    {
                                        RaisedNames.Add(name);
                                    }
                                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("RaisedNames"));
                                });
                            }
                            break;

                        case "ReceiveCloseHost":
                            if (!IsHost)
                            {
                                var leaveparms = new Dictionary <string, object>();
                                leaveparms.Add("HostCode", HostCode);
                                leaveparms.Add("Name", Name);
                                leaveparms.Add("IsHost", IsHost);
                                ConnectEvent.Instance.Publish(new Connect()
                                {
                                    Method = "Set", Parms = leaveparms
                                });
                                _navigation.GoBack();
                            }
                            break;
                        }
                    }
                }
            });
            LoadedCommand    = new DelegateCommand(OnLoaded);
            LeaveCommand     = new DelegateCommand(OnLeave);
            RaiseHandCommand = new DelegateCommand <string>(OnRaiseHand);
        }