Пример #1
0
 public static WapPush GetInstance()
 {
     if (null == push)
     {
         push = new WapPush();
     }
     return(push);
 }
Пример #2
0
        internal void SetHeader()
        {
            if (string.IsNullOrEmpty(WapURL))
            {
                //byte[] buf;
                switch (this._MessageCoding)
                {
                case 8:
                    _Msg_Content_Bytes = Encoding.BigEndianUnicode.GetBytes(this._MessageContent);
                    break;

                case 15:     //gb2312
                    _Msg_Content_Bytes = Encoding.GetEncoding("gb2312").GetBytes(this._MessageContent);
                    break;

                case 0:     //ascii
                case 3:     //短信写卡操作
                case 4:     //二进制信息
                default:
                    _Msg_Content_Bytes = Encoding.ASCII.GetBytes(this._MessageContent);
                    break;
                }

                if (this.Pk_total > 1) //长短信
                {
                    this.TP_udhi = 1;
                    byte[] tp_udhiHead = new byte[6];
                    tp_udhiHead[0] = 0x05;
                    tp_udhiHead[1] = 0x00;
                    tp_udhiHead[2] = 0x03;
                    tp_udhiHead[3] = 0x0A;
                    tp_udhiHead[4] = (byte)this.Pk_total;
                    tp_udhiHead[5] = (byte)this.Pk_number;
                    byte[] Msg_Content_Bytes_Temp = new byte[_Msg_Content_Bytes.Length + 6];
                    int    index = 0;
                    tp_udhiHead.CopyTo(Msg_Content_Bytes_Temp, index);
                    index += tp_udhiHead.Length;
                    _Msg_Content_Bytes.CopyTo(Msg_Content_Bytes_Temp, index);
                    _Msg_Content_Bytes = Msg_Content_Bytes_Temp;
                }
            }
            else
            {
                _Msg_Content_Bytes  = WapPush.GetInstance().toBytes(this._MessageContent, WapURL);
                this._MessageCoding = 0x04;
                this.TP_pid         = 1;
                this.TP_udhi        = 1;
            }

            this._MessageLength = (uint)_Msg_Content_Bytes.Length;
            this._BodyLength    = (int)(FixedBodyLength + this._MessageLength);
            this._Header        = new SGIP_MESSAGE((uint)(SGIP_MESSAGE.Length + this._BodyLength), SGIP_COMMAND.SGIP_SUBMIT, this._Sequence_Id);
        }