private void button1_Click(object sender, EventArgs e) { if (!client.Connected) { client.RemoteEndPoint = new IPEndPoint(IPAddress.Parse(txtHost.Text), 8090); client.DelimiterType = DelimiterType.dtMessageTailExcludeOnReceive; client.Delimiter = new byte[] { 0xAA, 0xFF, 0xAA }; client.EncryptType = EncryptType.etRijndael; client.CompressionType = CompressionType.ctNone; client.SocketBufferSize = 1024; client.MessageBufferSize = 512; client.Connect(); if (client.Connected) { this.lstUsers.Items.Clear(); this.lstStatus.Items.Clear(); read = new Thread(new ParameterizedThreadStart(ThreadExecute)); read.Start(client); ChatMessage msg = new ChatMessage(); msg.MessageType = MessageType.mtLogin; msg.UserInfo = new UserInfo[1]; msg.UserInfo[0].UserName = txtNickName.Text; client.Write(ChatSocketService.ChatSocketService.SerializeMessage(msg)); } else { UpdateList("Not Connected! " + client.LastException != null ? client.LastException.Message : String.Empty); } } }
private void button1_Click(object sender, EventArgs e) { if (!client.Connected) { client.RemoteEndPoint = new IPEndPoint(IPAddress.Parse(txtHost.Text), Convert.ToInt32(txtPort.Text)); client.DelimiterType = (DelimiterType)Enum.Parse(typeof(DelimiterType), cboDelimiter.Text); client.Delimiter = Encoding.GetEncoding(1252).GetBytes(txtDelimiter.Text); client.EncryptType = (EncryptType)Enum.Parse(typeof(EncryptType), cboEncrypt.Text); client.CompressionType = (CompressionType)Enum.Parse(typeof(CompressionType), cboCompression.Text); client.SocketBufferSize = 256; client.MessageBufferSize = 512; if (cboProxyType.SelectedIndex > -1) { client.ProxyInfo = new ProxyInfo((ProxyType)Enum.Parse(typeof(ProxyType), cboProxyType.Text), new IPEndPoint(IPAddress.Parse(txtProxyHost.Text), Convert.ToInt32(txtProxyPort.Text)), new NetworkCredential(txtProxyUser.Text, txtProxyPass.Text, txtProxyDomain.Text)); } client.Connect(); if (client.Connected) { UpdateList("Connected!"); read = new Thread(new ParameterizedThreadStart(ThreadExecute)); read.Start(client); } else { UpdateList("Not Connected! " + client.LastException != null ? client.LastException.Message : String.Empty); } } }