private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         var response = _webApiClient.Account.Login(new LoginRequest()
         {
             UserID = tbUserID.Text, Password = tbPassword.Text
         });
         AppendLine($"User `{tbUserID.Text}` logged in.");
         tbSessionID.Text = response.SessionID;
         _chatClient      = new ChatClientModule($"http://{_config.ServerIP}:{_config.ChatPort}/", tbUserID.Text, response.SessionID);
         _chatClient.Hub.SubscribeOn <MessageParam>(c => c.Message, msg =>
         {
             Invoke(() =>
             {
                 ConversationForm form = StartConversation(msg.SenderUserID);
                 form.AppendMessageFromOtherUser(msg.Message);
             });
         });
         _chatClient.Hub.SubscribeOn <ClientListParam>(c => c.ClientList, msg =>
         {
             Invoke(() => FillUserList(msg.Clients));
         });
         _voipClient = new VoipClientModule(_config.ServerIP, _config.SipPort);
         _voipClient.PhoneStateChanged += VoipClientOnPhoneStateChanged;
         _voipClient.Register(tbUserID.Text, tbSessionID.Text);
         SetControlsToLoginState(true);
     }
     catch (WebApiException ex)
     {
         AppendLine($"Could not log in: {ex.ResponseCode} {ex.ResponseMessage}");
     }
 }
 private void btnLogout_Click(object sender, EventArgs e)
 {
     try
     {
         _forms.ForEach((x) =>
         {
             x.Value.Close();
         });
         _forms.Clear();
         _voipClient.PhoneStateChanged -= VoipClientOnPhoneStateChanged;
         _voipClient.Dispose();
         _voipClient = null;
         _chatClient.Dispose();
         _chatClient = null;
         _webApiClient.Account.Logout(new LogoutRequest()
         {
             SessionID = tbSessionID.Text
         });
         SetControlsToLoginState(false);
         tbPassword.Clear();
         tbSessionID.Clear();
         lbOtherUsers.Items.Clear();
         tbLog.Clear();
     }
     catch (WebApiException ex)
     {
         AppendLine($"Could not log out: {ex.ResponseCode} {ex.ResponseMessage}");
     }
 }
Exemple #3
0
 public ConversationForm(string thisUserId, string otherUserId, string hash_pass, VoipClientModule voipClient)
 {
     _thisUserId  = thisUserId;
     _otherUserId = otherUserId;
     _voipClient  = voipClient;
     InitializeComponent();
     this.Text  = $"Conversation with {otherUserId}";
     _htmlPanel = new HtmlPanel();
     panel1.Controls.Add(_htmlPanel);
     _htmlPanel.Dock = DockStyle.Fill;
     _voipClient.PhoneStateChanged += VoipClientOnPhoneStateChanged;
 }