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

📄 multipushmsg.java

📁 MM7彩信对接网关示例
💻 JAVA
字号:
/*
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.rainbow.mms.golden.base;

import java.io.ByteArrayOutputStream;

public class MultiPushMsg extends SMSPushMessage {
	
	/**
	 * @param href
	 * @param text
	 */
	public MultiPushMsg(String href, String text) {
		super(href, text);
		// TODO Auto-generated constructor stub
	}

	public byte[] getSMSBytes() {
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		byte[] body = GetPDUBytes();
		int length = body.length;
		boolean singleSms = this.isSingleMsg(length);
		if (singleSms) {
			byte[] wdpHeader = GetWDPHeaderBytes();
			stream.write(wdpHeader, 0, wdpHeader.length);
			byte[] pdu = GetPDUBytes();
			stream.write(pdu, 0, pdu.length);
		} else {
			int total = (int) length / 128 + 1;
			System.out.println("total"+total);
			for (int index = 1; index <= total; index++) {
				byte[] wdpHeader = GetMutiWDPHeaderBytes(total, index);
				stream.write(wdpHeader, 0, wdpHeader.length);
				//byte[] temp = new byte[128];
				//System.out.println(length);
				//System.out.println("count" + index);
				int arrayCopyFrom = (index - 1) * 128;
				//int arrayCopyTo = (count - 1) * 128 + 128;
				if (index != total){
					byte[] temp = new byte[128];
					System.arraycopy(body, arrayCopyFrom, temp, 0, 128);//不是最后一个包
					stream.write(temp, 0, temp.length);
				}
				else{
					int lastLength=length-(index-1)*128;
					byte[] temp = new byte[lastLength];
					System.out.println("lastLength"+lastLength);
					System.arraycopy(body,arrayCopyFrom,temp,0,lastLength);
					stream.write(temp,0,lastLength);
				}
				
			}
		}

		return stream.toByteArray();
	}
	
	private boolean isSingleMsg(int length){
		boolean singleMsg = true;
		if (length > 133)
			singleMsg  = false;
		return singleMsg;
	}
}

⌨️ 快捷键说明

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