⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 submit.java

📁 短信服务的源码,可以连接联通SMG等短信网关进行短信发送
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        MOrelatetoMTFlag = i1;
        Priority = j1;
        ExpireTime = s7;
        ScheduleTime = s8;
        ReportFlag = k1;
        TP_pid = l1;
        TP_udhi = i2;
        MessageCoding = j2;
        MessageType = k2;
        MessageContent = s9;
        linkID1 = linkid1;
        linkID2 =linkid2;
    }

    public Submit(long l, String s, String s1, int i, String s2, String s3,
            String s4, int j, String s5, String s6, int k, int i1, int j1,
            String s7, String s8, int k1, int l1, int i2, int j2, int k2,
            int l2, byte abyte0[],int linkid1,int linkid2)
        throws SGIP_Exception
    {
        super(l);
        NodeID = 0L;
        ContentLength = 0;
        NodeID = l;
        SPNumber = s;
        ChargeNumber = s1;
        UserCount = 0;
        for(int i3 = 0; i3 < s2.length(); i3++)
        {
            char c = s2.charAt(i3);
            if(c != ',' && (c < '0' || c > '9'))
                throw new SGIP_Exception("Invalid Mobile Number");
            if(c == ',')
                UserCount++;
        }

        UserCount++;
        if(UserCount > 100)
            throw new SGIP_Exception("Too many users!");
        usernumber = new String[UserCount];
        boolean flag = false;
        int l3 = 0;
        for(int j3 = 0; j3 < UserCount - 1; j3++)
        {
            int k3 = l3;
            l3 = s2.indexOf(44, l3 + 1);
            usernumber[j3] = s2.substring(k3, l3);
            l3++;
        }

        usernumber[UserCount - 1] = s2.substring(l3, s2.length());
        CorpId = s3;
        ServiceType = s4;
        FeeType = j;
        FeeValue = s5;
        GivenValue = s6;
        AgentFlag = k;
        MOrelatetoMTFlag = i1;
        Priority = j1;
        ExpireTime = s7;
        ScheduleTime = s8;
        ReportFlag = k1;
        TP_pid = l1;
        TP_udhi = i2;
        MessageCoding = j2;
        MessageType = k2;
        ContentLength = l2;
        BinContent = new byte[l2];
        SGIP_Command.BytesCopy(abyte0, BinContent, 0, ContentLength - 1, 0);
        linkID1 = linkid1;
        linkID2 =linkid2;
    }

    private void SetMsgBody()
        throws SGIP_Exception
    {
        byte abyte0[] = null;
        try
        {
            if(MessageCoding == 15)
            {
                abyte0 = MessageContent.getBytes("GBK");
                ContentLength = abyte0.length;
            } else
            {
                ContentLength = MessageContent.length();
            }
        }
        catch(Exception exception)
        {
            System.out.println("chinese code error:" + exception.toString());
        }
        TotalLength = 143 + 21 * UserCount + ContentLength;
        head.setTotalLength(TotalLength);
        head.setCommandID(3);
        head.setSeq_1(SGIP_Command.seq.getGlobalSeq_1());
        head.setSeq_2(SGIP_Command.seq.getGlobalSeq_2());
        head.setSeq_3(SGIP_Command.seq.getGlobalSeq_3());
        bodybytes = new byte[TotalLength - 20];
        byte abyte1[] = new byte[21];
        if(SPNumber.length() > 21)
            throw new SGIP_Exception("SPNumber Longer than 21 bytes:" + SPNumber);
        SPNumber.getBytes(0, SPNumber.length(), abyte1, 0);
        SGIP_Command.BytesCopy(abyte1, bodybytes, 0, 20, 0);
        abyte1 = new byte[21];
        if(ChargeNumber.length() > 21)
            throw new SGIP_Exception("ChargeNumber longer than 21 bytes:" + ChargeNumber);
        ChargeNumber.getBytes(0, ChargeNumber.length(), abyte1, 0);
        SGIP_Command.BytesCopy(abyte1, bodybytes, 0, 20, 21);
        bodybytes[42] = (byte)UserCount;
        UserCount = UserCount;
        int i = 43;
        for(int j = 0; j < UserCount; j++)
        {
            abyte1 = new byte[21];
            String s = new String(usernumber[j]);
            if(s.length() > 21)
                throw new SGIP_Exception("UserNumber longer than 21 bytes:" + s);
            s.getBytes(0, s.length(), abyte1, 0);
            SGIP_Command.BytesCopy(abyte1, bodybytes, 0, 20, i);
            i += 21;
        }

        abyte1 = new byte[5];
        if(CorpId.length() > 5)
            throw new SGIP_Exception("CorpId longer than 5 bytes:" + CorpId);
        CorpId.getBytes(0, CorpId.length(), abyte1, 0);
        SGIP_Command.BytesCopy(abyte1, bodybytes, 0, 4, i);
        i += 5;
        abyte1 = new byte[10];
        if(ServiceType.length() > 10)
            throw new SGIP_Exception("ServiceType longer than 10 bytes:" + ServiceType);
        ServiceType.getBytes(0, ServiceType.length(), abyte1, 0);
        SGIP_Command.BytesCopy(abyte1, bodybytes, 0, 9, i);
        i += 10;
        bodybytes[i] = (byte)FeeType;
        i++;
        abyte1 = new byte[6];
        if(FeeValue.length() > 6)
            throw new SGIP_Exception("FeeValue longer than 6 bytes:" + FeeValue);
        FeeValue.getBytes(0, FeeValue.length(), abyte1, 0);
        SGIP_Command.BytesCopy(abyte1, bodybytes, 0, 5, i);
        i += 6;
        abyte1 = new byte[6];
        if(GivenValue.length() > 6)
            throw new SGIP_Exception("GivenValue longer than 6 bytes:" + GivenValue);
        GivenValue.getBytes(0, GivenValue.length(), abyte1, 0);
        SGIP_Command.BytesCopy(abyte1, bodybytes, 0, 5, i);
        i += 6;
        bodybytes[i] = (byte)AgentFlag;
        i++;
        bodybytes[i] = (byte)MOrelatetoMTFlag;
        i++;
        bodybytes[i] = (byte)Priority;
        i++;
        abyte1 = new byte[16];
        if(ExpireTime.length() > 16)
            throw new SGIP_Exception("EXpireTime longer than 16 bytes:" + ExpireTime);
        ExpireTime.getBytes(0, ExpireTime.length(), abyte1, 0);
        SGIP_Command.BytesCopy(abyte1, bodybytes, 0, 15, i);
        i += 16;
        abyte1 = new byte[16];
        if(ScheduleTime.length() > 16)
            throw new SGIP_Exception("ScheduleTime longer than 16 bytes:" + ScheduleTime);
        ScheduleTime.getBytes(0, ScheduleTime.length(), abyte1, 0);
        SGIP_Command.BytesCopy(abyte1, bodybytes, 0, 15, i);
        i += 16;
        bodybytes[i] = (byte)ReportFlag;
        i++;
        bodybytes[i] = (byte)TP_pid;
        i++;
        bodybytes[i] = (byte)TP_udhi;
        i++;
        bodybytes[i] = (byte)MessageCoding;
        i++;
        bodybytes[i] = (byte)MessageType;
        i++;
        SGIP_Command.BytesCopy(SGIP_Command.IntToBytes4(ContentLength), bodybytes, 0, 3, i);
        i += 4;
        boolean flag = false;
        if(MessageCoding == 15)
            SGIP_Command.BytesCopy(abyte0, bodybytes, 0, ContentLength - 1, i);
        else
            MessageContent.getBytes(0, ContentLength, bodybytes, i);

        byte[] tmp = new byte[4];

        tmp = SGIP_Command.IntToBytes4(linkID1);

        SGIP_Command.BytesCopy(tmp,bodybytes,0,3,bodybytes.length-8);

        tmp = SGIP_Command.IntToBytes4(linkID2);

        SGIP_Command.BytesCopy(tmp,bodybytes,0,3,bodybytes.length-4);
    }

    private void SetBinBody()
        throws SGIP_Exception
    {
        TotalLength = 143 + 21 * UserCount + ContentLength;
        if(SGIP_Command.seq == null)
        {
            SGIP_Command.seq = new Seq();
            SGIP_Command.seq.setNodeId(NodeID);
            Seq.computeSequence();
        }
        head.setTotalLength(TotalLength);
        head.setCommandID(3);
        head.setSeq_1(SGIP_Command.seq.getGlobalSeq_1());
        head.setSeq_2(SGIP_Command.seq.getGlobalSeq_2());
        head.setSeq_3(SGIP_Command.seq.getGlobalSeq_3());
        bodybytes = new byte[TotalLength - 20];
        byte abyte0[] = new byte[21];
        if(SPNumber.length() > 21)
            throw new SGIP_Exception("SPNumber Longer than 21 bytes:" + SPNumber);
        SPNumber.getBytes(0, SPNumber.length(), abyte0, 0);
        SGIP_Command.BytesCopy(abyte0, bodybytes, 0, 20, 0);
        abyte0 = new byte[21];
        if(ChargeNumber.length() > 21)
            throw new SGIP_Exception("ChargeNumber longer than 21 bytes:" + ChargeNumber);
        ChargeNumber.getBytes(0, ChargeNumber.length(), abyte0, 0);
        SGIP_Command.BytesCopy(abyte0, bodybytes, 0, 20, 21);
        bodybytes[42] = (byte)UserCount;
        int i = 43;
        for(int j = 0; j < UserCount; j++)
        {
            abyte0 = new byte[21];
            String s = new String(usernumber[j]);
            if(s.length() > 21)
                throw new SGIP_Exception("UserNumber longer than 21 bytes:" + s);
            s.getBytes(0, s.length(), abyte0, 0);
            SGIP_Command.BytesCopy(abyte0, bodybytes, 0, 20, i);
            i += 21;
        }

        abyte0 = new byte[5];
        if(CorpId.length() > 5)
            throw new SGIP_Exception("CorpId longer than 5 bytes:" + CorpId);
        CorpId.getBytes(0, CorpId.length(), abyte0, 0);
        SGIP_Command.BytesCopy(abyte0, bodybytes, 0, 4, i);
        i += 5;
        abyte0 = new byte[10];
        if(ServiceType.length() > 10)
            throw new SGIP_Exception("ServiceType longer than 10 bytes:" + ServiceType);
        ServiceType.getBytes(0, ServiceType.length(), abyte0, 0);
        SGIP_Command.BytesCopy(abyte0, bodybytes, 0, 9, i);
        i += 10;
        bodybytes[i] = (byte)FeeType;
        i++;
        abyte0 = new byte[6];
        if(FeeValue.length() > 6)
            throw new SGIP_Exception("FeeValue longer than 6 bytes:" + FeeValue);
        FeeValue.getBytes(0, FeeValue.length(), abyte0, 0);
        SGIP_Command.BytesCopy(abyte0, bodybytes, 0, 5, i);
        i += 6;
        abyte0 = new byte[6];
        if(GivenValue.length() > 6)
            throw new SGIP_Exception("GivenValue longer than 6 bytes:" + GivenValue);
        GivenValue.getBytes(0, GivenValue.length(), abyte0, 0);
        SGIP_Command.BytesCopy(abyte0, bodybytes, 0, 5, i);
        i += 6;
        bodybytes[i] = (byte)AgentFlag;
        i++;
        bodybytes[i] = (byte)MOrelatetoMTFlag;
        i++;
        bodybytes[i] = (byte)Priority;
        i++;
        abyte0 = new byte[16];
        if(ExpireTime.length() > 16)
            throw new SGIP_Exception("EXpireTime longer than 16 bytes:" + ExpireTime);
        ExpireTime.getBytes(0, ExpireTime.length(), abyte0, 0);
        SGIP_Command.BytesCopy(abyte0, bodybytes, 0, 15, i);
        i += 16;
        abyte0 = new byte[16];
        if(ScheduleTime.length() > 16)
        {
            throw new SGIP_Exception("ScheduleTime longer than 16 bytes:" + ScheduleTime);
        } else
        {
            ScheduleTime.getBytes(0, ScheduleTime.length(), abyte0, 0);
            SGIP_Command.BytesCopy(abyte0, bodybytes, 0, 15, i);
            i += 16;
            bodybytes[i] = (byte)ReportFlag;
            i++;
            bodybytes[i] = (byte)TP_pid;
            i++;
            bodybytes[i] = (byte)TP_udhi;
            i++;
            bodybytes[i] = (byte)MessageCoding;
            i++;
            bodybytes[i] = (byte)MessageType;
            i++;
            SGIP_Command.BytesCopy(SGIP_Command.IntToBytes4(ContentLength), bodybytes, 0, 3, i);
            i += 4;
            SGIP_Command.BytesCopy(BinContent, bodybytes, 0, ContentLength - 1, i);
            return;
        }
    }

    public int write(OutputStream outputstream)
    {
        try
        {
            if(MessageCoding == 4)
                SetBinBody();
            else
                SetMsgBody();
            super.write(outputstream);
            return 0;
        }
        catch(Exception exception)
        {
            System.out.println(exception.toString());
        }
        return -1;
    }

    public int getLinkID1() {
        return linkID1;
    }

    public int getLinkID2() {
        return linkID2;
    }

    public void setLinkID1(int linkID1) {
        this.linkID1 = linkID1;
    }

    public void setLinkID2(int linkID2) {
        this.linkID2 = linkID2;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -