資源簡介
cmpp2.0 移動短信 實現長連接 心跳檢測 長短信發送功能

代碼片段和文件信息
package?com.qiji.chinamobile;
import?java.io.ByteArrayInputStream;
import?java.io.ByteArrayOutputStream;
import?java.io.DataInputStream;
import?java.io.IOException;
import?java.io.InputStream;
import?org.apache.log4j.Logger;
import?com.qiji.chinamobile.domain.MsgHead;
/**
?*?提交代碼后的應答消息解析.
?*?
?*/
public?class?MsgSubmitResp?extends?MsgHead?{
private?static?Logger?logger?=?Logger.getLogger(MsgSubmitResp.class);
private?long?msgId;
private?int?result;//?結果?0:正確?1:消息結構錯?2:命令字錯?3:消息序號重復?4:消息長度錯?5:資費代碼錯
//?6:超過最大信息長?7:業務代碼錯?8:流量控制錯?9:本網關不負責服務此計費號碼?10:Src_Id錯誤
//?11:Msg_src錯誤?12:Fee_terminal_Id錯誤
//?13:Dest_terminal_Id錯誤
/**
?*?@param?data
?*?byte[]
?*/
public?MsgSubmitResp(byte[]?data)?{
if?(data.length?==?21)?{//8?+?8?+?4??17
ByteArrayInputStream?bins?=?new?ByteArrayInputStream(data);
DataInputStream?dins?=?new?DataInputStream(bins);
try?{
// this.setTotalLength(data.length?+?4);
this.setTotalLength(data.length);
int?commandId??=?dins.readInt();
logger.info(“commandId:“?+?commandId);
//this.setCommandId(dins.readInt());
int?sequenceId??=?dins.readInt();
logger.info(“sequenceId:“?+?sequenceId);
//this.setSequenceId(dins.readInt());
this.msgId?=?dins.readLong();
logger.info(“msgId:“?+?msgId);
this.result?=?dins.readInt();
logger.info(“result:“?+?result);
dins.close();
bins.close();
logger.info(“msgId:“?+?msgId);
}?catch?(IOException?e)?{
e.printStackTrace();
}
}?else?{
logger.info(“發送短信IMSP回復解析數據包出錯,包長度不一致。長度為:“?+?data.length);
}
}
?/**?
?????*?@功能?讀取流?
?????*?@param?inStream?
?????*?@return?字節數組?
?????*?@throws?Exception?
?????*/??
????public?static?byte[]?readStream(InputStream?inStream)?throws?Exception?{??
????????ByteArrayOutputStream?outSteam?=?new?ByteArrayOutputStream();??
????????byte[]?buffer?=?new?byte[1024];??
????????int?len?=?-1;??
????????while?((len?=?inStream.read(buffer))?!=?-1)?{??
????????????outSteam.write(buffer?0?len);??
????????}??
????????outSteam.close();??
????????inStream.close();??
????????return?outSteam.toByteArray();??
????}?
????
public?long?getMsgId()?{
return?msgId;
}
public?void?setMsgId(long?msgId)?{
this.msgId?=?msgId;
}
public?int?getResult()?{
return?result;
}
public?void?setResult(int?result)?{
this.result?=?result;
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1317??2016-12-19?13:38??chinamobile\domain\MsgActiveTestResp.java
?????文件???????1008??2016-12-16?14:37??chinamobile\domain\MsgCommand.java
?????文件???????3372??2016-12-16?14:38??chinamobile\domain\MsgConnect.java
?????文件???????3631??2016-12-19?14:27??chinamobile\domain\MsgConnectResp.java
?????文件???????6909??2016-12-16?14:41??chinamobile\domain\MsgDeliver.java
?????文件???????1393??2016-12-16?14:42??chinamobile\domain\MsgDeliverResp.java
?????文件???????2431??2016-12-16?14:42??chinamobile\domain\MsgHead.java
?????文件???????8055??2016-12-16?14:42??chinamobile\domain\MsgSubmit.java
?????文件???????2684??2016-12-19?11:23??chinamobile\MsgSubmitResp.java
?????文件???????7094??2016-12-21?11:53??chinamobile\util\CmppSender.java
?????文件???????1008??2016-12-22?15:30??chinamobile\util\MsgActivityTimer.java
?????文件???????1628??2016-12-16?14:43??chinamobile\util\MsgConfig.java
?????文件??????22047??2016-12-23?10:00??chinamobile\util\MsgContainer.java
?????文件???????5806??2016-12-22?15:30??chinamobile\util\MsgUtils.java
?????目錄??????????0??2016-12-23?10:01??chinamobile\domain
?????目錄??????????0??2016-12-23?10:01??chinamobile\util
?????目錄??????????0??2016-12-23?10:01??chinamobile
-----------?---------??----------?-----??----
????????????????68383????????????????????17
評論
共有 條評論