wzp
2021-07-30 afda40ef498cca59e58b2b6869deae90f3c13de5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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;
        }
    }
}