/**
         * <summary>
         *   Creates a new empty SMS message, to be configured and sent later on.
         * <para>
         * </para>
         * </summary>
         * <param name="recipient">
         *   a text string with the recipient phone number, either as a
         *   national number, or in international format starting with a plus sign
         * </param>
         * <returns>
         *   <c>YAPI.SUCCESS</c> when the call succeeds.
         * </returns>
         * <para>
         *   On failure, throws an exception or returns a negative error code.
         * </para>
         */
        public virtual async Task <YSms> newMessage(string recipient)
        {
            YSms sms;

            sms = new YSms(this);
            await sms.set_recipient(recipient);

            return(sms);
        }
        /**
         * <summary>
         *   Sends a regular text SMS, with standard parameters.
         * <para>
         *   This function can send messages
         *   of more than 160 characters, using SMS concatenation. ISO-latin accented characters
         *   are supported. For sending messages with special unicode characters such as asian
         *   characters and emoticons, use <c>newMessage</c> to create a new message and define
         *   the content of using methods <c>addText</c> and <c>addUnicodeData</c>.
         * </para>
         * </summary>
         * <param name="recipient">
         *   a text string with the recipient phone number, either as a
         *   national number, or in international format starting with a plus sign
         * </param>
         * <param name="message">
         *   the text to be sent in the message
         * </param>
         * <returns>
         *   <c>YAPI.SUCCESS</c> when the call succeeds.
         * </returns>
         * <para>
         *   On failure, throws an exception or returns a negative error code.
         * </para>
         */
        public virtual async Task <int> sendTextMessage(string recipient, string message)
        {
            YSms sms;

            sms = new YSms(this);
            await sms.set_recipient(recipient);

            await sms.addText(message);

            return(await sms.send());
        }
Exemple #3
0
        public virtual async Task <int> generateParts()
        {
            int udhsize;
            int udlen;
            int mss;
            int partno;
            int partlen;

            byte[] newud;
            byte[] newudh;
            YSms   newpdu;
            int    i;
            int    wpos;

            udhsize = (_udh).Length;
            udlen   = (_udata).Length;
            mss     = 140 - 1 - 5 - udhsize;
            if (_alphab == 0)
            {
                mss = (((mss * 8 - 6)) / (7));
            }
            _npdu = (((udlen + mss - 1)) / (mss));
            _parts.Clear();
            partno = 0;
            wpos   = 0;
            while (wpos < udlen)
            {
                partno    = partno + 1;
                newudh    = new byte[5 + udhsize];
                newudh[0] = (byte)(0 & 0xff);       // IEI: concatenated message
                newudh[1] = (byte)(3 & 0xff);       // IEDL: 3 bytes
                newudh[2] = (byte)(_mref & 0xff);
                newudh[3] = (byte)(_npdu & 0xff);
                newudh[4] = (byte)(partno & 0xff);
                i         = 0;
                while (i < udhsize)
                {
                    newudh[5 + i] = (byte)(_udh[i] & 0xff);
                    i             = i + 1;
                }
                if (wpos + mss < udlen)
                {
                    partlen = mss;
                }
                else
                {
                    partlen = udlen - wpos;
                }
                newud = new byte[partlen];
                i     = 0;
                while (i < partlen)
                {
                    newud[i] = (byte)(_udata[wpos] & 0xff);
                    wpos     = wpos + 1;
                    i        = i + 1;
                }
                newpdu = new YSms(_mbox);
                await newpdu.set_received(await this.isReceived());

                await newpdu.set_smsc(await this.get_smsc());

                await newpdu.set_msgRef(await this.get_msgRef());

                await newpdu.set_sender(await this.get_sender());

                await newpdu.set_recipient(await this.get_recipient());

                await newpdu.set_protocolId(await this.get_protocolId());

                await newpdu.set_dcs(await this.get_dcs());

                await newpdu.set_timestamp(await this.get_timestamp());

                await newpdu.set_userDataHeader(newudh);

                await newpdu.set_userData(newud);

                _parts.Add(newpdu);
            }
            return(YAPI.SUCCESS);
        }