private async void StartChatting_Click(object sender, EventArgs e) {//dataformat : [&user1&user2&] if (friendsListBox.CheckedItems.Count < 1) { MessageBox.Show("혼자선 채팅할 수 없습니다."); return; } for (int i = 0; i < friendsListBox.CheckedItems.Count; i++) { foreach (string id in friendsListBox.UserState.Keys) { if (id.Equals(friendsListBox.CheckedItems[i].ToString()) && !friendsListBox.UserState[id]) { MessageBox.Show("로그아웃된 친구가 포함되어있습니다."); return; } } } if (DupleChecker.isOpen) { chatForm.Close(); chatForm = null; DupleChecker.isOpen = false; } count = 0; max = 0; selectedUserArray.Clear(); await Task.Run(() => { bool leastOne = false; selectedUser = null; selectedUser = "******" + this.id; //내아이디 string id = null; for (int i = 0; i < friendsListBox.Items.Count; i++) { id = friendsListBox.Items[i].ToString(); if (friendsListBox.GetItemChecked(friendsListBox.Items.IndexOf(id))) { leastOne = true; selectedUser += "&" + id; //선택한 아이디 max++; } } if (!leastOne) { selectedUser += "&]"; } else { selectedUser += "&]"; } string[] seluser = selectedUser.Split('&'); for (int i = 1; i < seluser.Length - 1; i++) { selectedUserArray.Add(seluser[i]); } byte[] MyId = Encoding.Default.GetBytes(selectedUser); N_stream.Write(MyId, 0, MyId.Length); }); }
private async void StartChatting_Click(object sender, EventArgs e) {//dataformat : [&user1&user2&] if (friendsListBox.CheckedItems.Count < 1) { MessageBox.Show("혼자선 채팅할 수 없습니다."); return; } await Task.Run(() => { bool leastOne = false; string selectedUser = "******" + this.id; string id = null; for (int i = 0; i < friendsListBox.Items.Count; i++) { id = friendsListBox.Items[i].ToString(); if (friendsListBox.GetItemChecked(friendsListBox.Items.IndexOf(id))) { leastOne = true; selectedUser += "&" + id; } } if (!leastOne) { selectedUser += "&]"; } else { selectedUser += "&]"; } byte[] MyId = Encoding.Default.GetBytes(selectedUser); N_stream.Write(MyId, 0, MyId.Length); }); }