private async void Submit_Click(object sender, RoutedEventArgs e) { // set url for local web server string url; if (address.Text != "") { url = address.Text; } else { url = "ws://127.0.0.1:15001"; } WebSocketForUser.Start(url); //if (WebSocketForUser.IsValid(new Server.DB.User() { ContactNickname = login.Text, Password = Password.Password })) //{ // ChatWindow chatWindow = new ChatWindow(login.Text, url); // chatWindow.Show(); // this.Close(); //} var parsed = await HTTP_SocketForUser.Auth_UserAsync(login.Text, Password.Password); if (parsed != null) { WebSocketForUser.AuthUser(login.Text, parsed["Cookie"].ToString()); ChatWindow chatWindow = new ChatWindow(login.Text, url); chatWindow.Show(); this.Close(); } }
//opens PersonToPerson chat private async void ContactList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { string id; ContactItemModel model = ((sender as ListView).SelectedItems[0]) as ContactItemModel; try { id = local_Groups.Where(w => w.GroupType == Local_Group.GroupTypes.PersonToPerson && ((w.Users[0].ContactNickname == model.ContactNickname && w.Users[1].ContactNickname == username) || (w.Users[1].ContactNickname == model.ContactNickname && w.Users[0].ContactNickname == username))).SingleOrDefault().GroupId; } catch { var parsed = await HTTP_SocketForUser.Create_Group(new List <User>() { user, new User() { Id = model.ApplicationUserId, ContactNickname = model.ContactNickname } }, model.ContactNickname + username, Local_Group.GroupTypes.PersonToPerson); id = parsed["Id"].ToString(); } await Dispatcher.BeginInvoke(new Action(() => { Chats.Items.Add(new TabItem() { Content = new Frame() { Content = new ChatPage(username, id, url) }, Header = model.ContactNickname }); })); }
private void CreateGroup_Click(object sender, RoutedEventArgs e) { HTTP_SocketForUser.Create_Group(group_users, tbGroupName.Text, Local_Group.GroupTypes.BigGroup); this.Close(); }