求助:聊天框的发送按钮代码怎么弄
如题,怎么办啊?
代码如下:
private void Send_MouseUp(object sender, MouseEventArgs e)
{
try
{
if(!privatemode)
{
string pubcommand="CHATI"+clientname+":"+ChatOut.Text+"\r\n";
Byte[] outbytes = System.Text.Encoding.ASCII.GetBytes(pubcommand.ToCharArray());
ns.Write(outbytes,0,outbytes.Length);
ChatOut.Text="";
}
else
{
if(IbChatters.SelectedIndex==-1)
{
MessageBox.Show("请从列表中选择一个对象!","错误",
MessageBoxButtons.OK,MessageBoxIcon.Exclamation.Exclamation);
return;
}
string destclient =IbChatters.SelectedItem.ToString();
string command = "PRIV" + clientname +"1:"+ChatOut.Text+"1"+destclient;
Byte[] outbytes = System.Text.Encoding.ASCII.GetBytes(command.ToCharArray());
ns.Write(outbytes,0,outbytes.Length);
ChatOut.Text="";
}
}
catch(Exception)
{
MessageBoxButtons("到服务器的连接丢失!","错误",
MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
ns.Close();
clientsocket.Close();
if(receive!=null && receive.IsAlive)
receive.Abort();
connected=false;
stausBar1.Text="已断开连接";
}
}
它说我很多都没定义。。。。。比如客户端之类的。怎么去定义那