示例#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
            }
        }
 //ctor:
 public ChatWindowViewModel(IUserName chosenContact)
 {
     ChosenContact = chosenContact;
     //init proxies:
     ChatServiceProxy = ChatServiceProxy.Instance;
     ChatServiceProxy.OnMessageSentEvent += ChatServiceProxy_OnMessageSentEvent;
     //init commands:
     SendMessageCommand = new MyCommand(SendMessage); //sendMessageRequest
 }
示例#3
0
        public ChatManager(
            ConnectionManager connectionManager,
            ChatServiceProxy chatServiceProxy,
            AccountManager accountManager)
            : base(connectionManager)
        {
            _chatServiceProxy = chatServiceProxy;
            _accountManager = accountManager;

            Messages = new ObservableCollection<Event>();
            OnlineUsers = new ObservableCollection<UserDto>();
        }
示例#4
0
        public Person[] Join(Person person, string serverIp, string port)
        {
            var chatCallback = new ChatServiceCallback();

            chatCallback.ChatCallbackEvent += ChatCallbackEvent;
            var uri = new Uri($"net.tcp://{serverIp}:{port}");

            _serviceProxy = new ChatServiceProxy(chatCallback, uri);
            var result = _serviceProxy.Join(person);

            return(result.Result);
        }
示例#5
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;
 }