Beispiel #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     vibrate();
     try
     {
         string receiver = myfriendinfo.id;
         //消息的格式是:命令标识符PRIV|发送者的用户名|接收者的用户名|发送内容|时间|
         string message  = "VIBRATE|" + Friends.myInfo.id + "|" + receiver + "|";
         byte[] outbytes = System.Text.Encoding.GetEncoding("gb2312").GetBytes(message.ToCharArray());   //将字符串转化为字符数组
         Friends.Stream.Write(outbytes, 0, outbytes.Length);
         MsgReceived.AppendText("您发送了一个窗口震动\n");
     }
     catch
     {
         MessageBox.Show("网络发生错误!");
     }
 }
Beispiel #2
0
 private void SendMsg_Click(object sender, EventArgs e)
 {
     try
     {
         string receiver = myfriendinfo.id;
         string time     = DateTime.Now.ToLongTimeString();
         string msg      = MsgToBeSent.Text;
         //消息的格式是:命令标识符PRIV|发送者的用户名|接收者的用户名|发送内容|时间|
         string message  = "PRIV|" + Friends.myInfo.id + "|" + receiver + "|" + msg + "|" + time + "|";
         byte[] outbytes = System.Text.Encoding.GetEncoding("gb2312").GetBytes(message.ToCharArray());   //将字符串转化为字符数组
         Friends.Stream.Write(outbytes, 0, outbytes.Length);
         MsgToBeSent.Clear();
         MsgReceived.AppendText(myid + "(" + time + ")" + "\n" + msg + "\n");
     }
     catch
     {
         MessageBox.Show("网络发生错误!");
     }
 }
Beispiel #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     MsgReceived.AppendText("---------------以上为历史消息---------------\n");
     this.Close();
 }