2013-01-21 77 views
4

我使用cloudhopper-smpp通过SMPP接收SMS。在实施DefaultSmppSessionHandler之后,SessionHandler正在接收PDU请求(在覆盖的firePduRequestReceived方法中)。从PduRequest获取短消息

是否有帮助程序/ Utils从PduRequestdeliver_sm类型中提取SMS? 找不到PduRequest中的任何获取者来访问SMS。

回答

7

找到了答案。

 if (pduRequest.getCommandId() == SmppConstants.CMD_ID_DELIVER_SM) { 
     DeliverSm mo = (DeliverSm) pduRequest; 
     int length = mo.getShortMessageLength(); 
     Address source_address = mo.getSourceAddress(); 
     Address dest_address = mo.getDestAddress(); 
     byte[] shortMessage = mo.getShortMessage(); 
     String SMS= new String(shortMessage); 
     }