namespace AsiaINFO.SMS.CMPP2 { using System; using System.Text; public class WapPush { private static readonly byte[] EndOfWapPush; private static WapPush push = null; private static readonly byte[] WapPushDisplayTextHeader; private static readonly byte[] WapPushHeader1 = new byte[] { 11, 5, 4, 11, 0x84, 0x23, 240, 0, 3, 3, 1, 1 }; private static readonly byte[] WapPushHeader2 = new byte[] { 0x29, 6, 6, 3, 0xae, 0x81, 0xea, 0x8d, 0xca }; private static readonly byte[] WapPushIndicator = new byte[] { 2, 5, 0x6a, 0, 0x45, 0xc6, 12, 3 }; static WapPush() { byte[] buffer = new byte[3]; buffer[1] = 1; buffer[2] = 3; WapPushDisplayTextHeader = buffer; byte[] buffer2 = new byte[3]; buffer2[1] = 1; buffer2[2] = 1; EndOfWapPush = buffer2; } public static WapPush GetInstance() { if (push == null) { push = new WapPush(); } return push; } public byte[] toBytes(string WAP_Msg, string WAP_URL) { byte[] array = new byte[400]; int index = 0; WapPushHeader1.CopyTo(array, index); index += WapPushHeader1.Length; WapPushHeader2.CopyTo(array, index); index += WapPushHeader2.Length; WapPushIndicator.CopyTo(array, index); index += WapPushIndicator.Length; byte[] bytes = Encoding.UTF8.GetBytes(WAP_URL); bytes.CopyTo(array, index); index += bytes.Length; WapPushDisplayTextHeader.CopyTo(array, index); index += WapPushDisplayTextHeader.Length; byte[] buffer3 = Encoding.UTF8.GetBytes(WAP_Msg); buffer3.CopyTo(array, index); index += buffer3.Length; EndOfWapPush.CopyTo(array, index); index += 3; byte[] buffer4 = new byte[index]; for (int i = 0; i < buffer4.Length; i++) { buffer4 = array; } return buffer4; } } }