public Chat() { InitializeComponent(); #region 可以删除但是单独运行,请把它注释掉 qq = new ProtocolQQ(); utu = new UTU(); #endregion }
private void ClosePic_Click(object sender, EventArgs e) { //让服务器端知道该用户马上下线 ProtocolQQ qq = new ProtocolQQ(); qq.mode = 3; qq.ope = 0; qq.data = null; Variable.client.SendMsg(qq); Application.ExitThread();//退出当前应用程序 }
/// <summary> /// 客户端发送消息 /// </summary> /// <param name="qq"></param> public void SendMsg(ProtocolQQ qq) { MemoryStream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, qq); byte[] msg = stream.GetBuffer(); client.Send(msg); // Thread.Sleep(5000); }
private void closeBut_Click(object sender, EventArgs e) { //??????? //差一个下线消息!!! ProtocolQQ qq = new ProtocolQQ(); qq.mode = 3; qq.ope = 0; qq.data = null; Variable.client.SendMsg(qq); Application.ExitThread();//退出当前应用程序 }
public Y() { InitializeComponent(); protocolqq = new ProtocolQQ(); //将已经处理好的背景图片放入数组中 bkImageLis.LoadImg(); //建立一个用户登录对象 userLogin = new UserLogin(); //建立一个本地用户类 //l_ = new LocMess(); //将反序列化的数据放入字典中,这个有点简单(语法) //ls = new Dictionary<string, LocMess>(); }
/// <summary> /// 服务器端向客户端发送消息 /// </summary> /// <param name="mode"></param> /// <param name="oper"></param> /// <param name="obj"></param> /// <returns></returns> byte[] SendMsg(int mode, int oper, object obj) { ProtocolQQ qq = new ProtocolQQ(); qq.mode = mode; qq.ope = oper; qq.data = obj; MemoryStream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, qq); byte[] msg = stream.GetBuffer(); return(msg); }
public Login() { InitializeComponent(); protocolqq = new ProtocolQQ(); oldIdFont = idTextBox.Font; oldPswFont = pswTextBox.Font; headPic = new MyPicture(); //新建本地用户类 #region 记到莫乱删 //网络套接字------ user = new clientUser(); user.Start(); Variable.client = user; //建立一个用户登录对象 userLogin = new UserLogin(); //建立一个本地用户类 l = new LocMess(); ls = new Dictionary <string, LocMess>(); #endregion }
//点击注册事件 private void ZC_Click(object sender, EventArgs e) { if (psw.Text.Trim() == "" || pswPlus.Text.Trim() == "" || name.Text.Trim() == "") { MessageBox.Show("昵称或者密码设置为空,请重新输入", "提示"); } if (psw.Text.Trim() != pswPlus.Text.Trim()) { MessageBox.Show("两次密码输入不一致,请重新输入"); pswPlus.Focus(); } else { ProtocolQQ qq = new ProtocolQQ(); Regr reger = new Regr(); qq.mode = 0; qq.ope = 1; reger.NickName = name.Text.Trim(); reger.PSW = psw.Text.Trim(); qq.data = reger; Variable.client.SendMsg(qq); } }
public forget() { InitializeComponent(); qq = new ProtocolQQ(); }