/// <summary> /// Constructor which accepts Client TCP object. /// </summary> /// <param name="parentForm"></param> /// <param name="tcpClient"></param> public ChatDialogForm(StaffChatForm parentForm, TcpClient tcpClient, StaffModel s) { InitializeComponent(); this.ownerForm = parentForm; staffMember = s; connectedStudent = null; //Get stream object connectedClient = tcpClient; clientStream = tcpClient.GetStream(); //Create the state object state = new StateObject(); state.workSocket = connectedClient.Client; //Set properties remoteEndPoint = ((IPEndPoint)state.workSocket.RemoteEndPoint).Address.ToString(); remotePort = ((IPEndPoint)state.workSocket.RemoteEndPoint).Port.ToString(); //Send the RSA public key SendPublicKey(); //Call asynchronous receive function connectedClient.Client.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(OnReceive), state); TextBoxConnectionStatus.BackColor = Color.Green; }
private void ButtonOpenChat_Click(object sender, EventArgs e) { StaffChatForm staffChatForm = new StaffChatForm(staffMember); staffChatForm.ShowDialog(); }