/// <summary> /// AS的int转byte[] /// </summary> /// <param name="i"></param> /// <returns></returns> public static byte[] ASIntToByte(uint i) { ByteArray ba = new ByteArray(); ba.WriteObject(i); byte[] ss = new byte[16]; ba.Position = 1; ba.ReadBytes(ss, 0, (uint)ss.Length); byte[] rs = new byte[ba.Length - 1]; for (int j = 0; j < rs.Length; j++) rs[j] = ss[j]; return rs; }
/// <summary> /// 刷花 /// </summary> public void Flower() { if ((!isLogined))//未登录 return; if(Common.micQueue.Count < 1)//无麦序 return; if (!ready)//未就绪 return; if (!changeChannelOk)//未加入频道 return; //uint my = 795759530; //uint mic = 113581884; uint m = 1; uint maxtype = 10; uint mintype = 3; //pack ByteArray pack = new ByteArray(); pack.WriteUnsignedInt(Common.endianLittleBig(uid)); pack.WriteUnsignedInt(Common.endianLittleBig(Common.micQueue[0])); pack.WriteUnsignedInt(Common.endianLittleBig(m));//刷的数量,且为1 //data ByteArray data = new ByteArray(); data.WriteUnsignedInt(Common.endianLittleBig(maxtype)); data.WriteUnsignedInt(Common.endianLittleBig(mintype)); UInt16 pl = (UInt16)pack.Length; short plength = (short)Common.endianLittleBig(pl); data.WriteShort(plength); byte[] buf = new byte[pack.Length]; pack.Position = 0; pack.ReadBytes(buf, (uint)0, (uint)buf.Length); data.WriteBytes(buf, 0, buf.Length); byte[] databuf = new byte[data.Length]; data.Position = 0; data.ReadBytes(databuf, (uint)0, (uint)databuf.Length); //senddata //00:00:00: 42 :0a:0b:01:07:75:72:69:04:82:46:19:61:70:70:5f:64:61:74:61:5f:72:65:71:0a:01:05:69:64:04:f5:1b:09:64:61:74:61:0c:2d: 0a:00:00:00:03:00:00:00:0c:00:aa:53:6e:2f:3c:1f:c5:06:01:00:00:00: 01:01 //00:00:00: 42 :0a:0b:01:07:75:72:69:04:82:46:19:61:70:70:5f:64:61:74:61:5f:72:65:71:0a:01:05:69:64:04:f5:1b:09:64:61:74:61:0c:2d: 0a:00:00:00:03:00:00:00:0c:00:aa:53:6e:2f:3c:1f:c5:06:01:00:00:00: 01:01 //00:00:00: 42: 0a:0b:01:07:75:72:69:04:82:46:19:61:70:70:5f:64:61:74:61:5f:72:65:71:0a:01:05:69:64:04:f5:1b:09:64:61:74:61:0c:2d: 0a:00:00:00:03:00:00:00:0c:00:aa:53:6e:2f:39:73:65:0b:01:00:00:00: 01:01 // byte[] front = { 0, 0, 0, 66, 10, 11, 1, 7, 117, 114, 105, 4, 130, 70, 25, 97, 112, 112, 95, 100, 97, 116, 97, 95, 114, 101, 113, 10, 1, 5, 105, 100, 4, 245, 27, 9, 100, 97, 116, 97, 12, 45 }; byte[] back = { 1, 1 }; //长度 int length = front.Length + databuf.Length + back.Length; front[3] = (byte)length; //组 int sendBuffIndex = 0; byte[] sendBuff = new byte[length]; front.CopyTo(sendBuff, sendBuffIndex); sendBuffIndex += front.Length; databuf.CopyTo(sendBuff, sendBuffIndex); sendBuffIndex += databuf.Length; back.CopyTo(sendBuff, sendBuffIndex); socket.Send(sendBuff); lastMsg = "完成刷花:"+DateTime.Now; }