コード例 #1
0
        private void SendLoginRequest()
        {
            LoginResponse response = UserServiceProxy.Login(new LoginRequest {
                UserName = this.UserName, Password = this.Password
            });

            ConsoleLog.Document += $" { response.IsSuccess } {response.Message} \n ";
            if (response.IsSuccess == true)
            {
                //save loged user authentication
                AuthenticatedUser.Authentication = response.Authentication;
                AuthenticatedUser.UserName       = this.UserName;
                //update contactList
                ContactStateManager.AssignAllCurrentOnlineContacts(response.AllOtherUsers);
                //joining the chat service:
                JoinChatServiceResponse responseFromChatService = ChatServiceProxy.JoinService(new JoinChatServiceRequest());
                ConsoleLog.Document += responseFromChatService.Message;
                //joining the Game Service:
                JoinGameServiceResponse responseFromGameService = GameServiceProxy.JoinService(new JoinGameServiceRequest());
                ConsoleLog.Document           += responseFromGameService.Message;
                UserServiceProxy.OnLoginEvent += UserServiceProxy_OnLoginEvent;
                ViewChanging("ContactListView");
                //set online users to something : new class that will save online users
            }
        }
コード例 #2
0
 private void UserServiceProxy_OnLoginEvent(object sender, OnLoginEventArgs e)
 {
     OnlineUsers         = new ObservableCollection <UserDTO>(ContactStateManager.GetOnlineContacts());
     OfflineUsers        = new ObservableCollection <UserDTO>(ContactStateManager.GetOfflineContacts());
     ConsoleLog.Document = e.UserName + "has loged in";
     //OnlineUsers.Add(new UserDTO {UserName= e.UserName });
 }
コード例 #3
0
 public void OnSignedUp(OnSignedUpRequest userSignedUp)
 {
     ContactStateManager.AddNewSignedContact(new UserDTO {
         UserName = userSignedUp.UserName
     });
     OnSignedUpEvent?.Invoke(this, new OnSignedUpEventArgs {
         UserName = userSignedUp.UserName
     });
 }
コード例 #4
0
 public void OnLogout(OnlogoutRequest userLogedout)
 {
     ContactStateManager.UpdateContactToOffline(new UserDTO {
         UserName = userLogedout.UserName
     });
     OnLogoutEvent?.Invoke(this, new OnLogoutEventArgs {
         UserName = userLogedout.UserName
     });
 }
コード例 #5
0
 public void OnLogin(OnLoginRequest userLogedin) // call back from server about new user that logged in
 {
     //adding the new logedin to the OnlineUsers:
     ContactStateManager.UpdateContactToOnline(new UserDTO {
         UserName = userLogedin.UserName
     });
     //raising the event:
     OnLoginEvent?.Invoke(this, new OnLoginEventArgs {
         UserName = userLogedin.UserName
     });
     //TODO: implement a info to the wpf about the user.
     // return new OnLoginResponse { IsSuccess = true, Message = "here the user info", userAlreadyLoged = new UserDTO { UserName = "******" } };
 }
コード例 #6
0
        private void SendSignUpRequest()
        {
            SignUpResponse response = UserServiceProxy.SignUp(new SignUpRequest {
                UserName = UserName, Password = Password, PasswordConfirm = PasswordConfirm
            });

            ConsoleLog.Document += $" {response.IsSuccess} {response.Message}";
            //update ContactsManager:
            if (response.IsSuccess == true)
            {
                response.AllOtherSignedUpUsers.ForEach(u => ConsoleLog.Document += $"other users: \n{u.UserName}");
                ContactStateManager.AssignAllCurrentContacts(response.AllOtherSignedUpUsers);
            }
        }
コード例 #7
0
        public LoginViewModel()
        {
            ConsoleLog = new ConsoleLog {
                Document = "check binding \n"
            };                                                             //test
            AuthenticatedUser = AuthenticatedUser.Instance;
            //load all contacts:
            ContactStateManager.LoadAllContacts();
            //init Proxies:
            UserServiceProxy = UserServiceProxy.Instance;
            ChatServiceProxy = ChatServiceProxy.Instance;
            GameServiceProxy = GameServiceProxy.Instance;

            //Init Commands:
            SendLoginRequestCommand   = new MyCommand(SendLoginRequest);
            ChangeViewToSignUpCommand = new MyCommand(ChangeViewToSignUp);
        }
コード例 #8
0
 //ctor:
 public ContactListViewModel()
 {
     onlineUsers  = new ObservableCollection <UserDTO>(ContactStateManager.GetOnlineContacts());
     offlineUsers = new ObservableCollection <UserDTO>(ContactStateManager.GetOfflineContacts());
     ConsoleLog   = new ConsoleLog();
     //init proxies:
     UserServiceProxy = UserServiceProxy.Instance;  //TODO: is needed?
     UserServiceProxy.OnLoginEvent    += UserServiceProxy_OnLoginEvent;
     UserServiceProxy.OnSignedUpEvent += UserServiceProxy_OnSignedUp;
     UserServiceProxy.OnLogoutEvent   += UserServiceProxy_OnLogout;
     ChatServiceProxy = ChatServiceProxy.Instance;
     ChatServiceProxy.OnMessageSentEvent += ChatServiceProxy_OnMessageSent;
     GameServiceProxy              = GameServiceProxy.Instance;
     GameServiceProxy.OnGameEvent += GameServiceProxy_OnGameEvent;
     //init ICommands:
     SendGameRequestCommand = new MyCommand(SendGameRequest);
     OpenChatWindowCommand  = new MyCommand(OpenChatWindow);
     //subscribe to Closing Window event:
     Application.Current.MainWindow.Closing += MainWindow_OnWindowClosing;
 }
コード例 #9
0
 private void UserServiceProxy_OnLogout(object sender, OnLogoutEventArgs e)
 {
     OnlineUsers          = new ObservableCollection <UserDTO>(ContactStateManager.GetOnlineContacts());
     OfflineUsers         = new ObservableCollection <UserDTO>(ContactStateManager.GetOfflineContacts());
     ConsoleLog.Document += $"{e.UserName} has loged out";
 }
コード例 #10
0
 private void UserServiceProxy_OnSignedUp(object sender, OnSignedUpEventArgs e)
 {
     //Getting the updated Offline contacts list:
     OfflineUsers        = new ObservableCollection <UserDTO>(ContactStateManager.GetOfflineContacts());
     ConsoleLog.Document = e.UserName + "has singed up";
 }