lizongbo at 618119.com 工作,生活,Android,前端,Linode,Ubuntu,nginx,java,apache,tomcat,Resin,mina,Hessian,XMPP,RPC

2007年12月6日

用Spring,smppapi,apache mina, commons ssl快速实现安全的smpp smsc (四)

Filed under: Java,SSL — 标签:, , , , , , — lizongbo @ 09:18

接上一篇: http://618119.com/archives/2007/12/03/35.html

对 SMPPPacket的业务处理代码:

1.处理 BIND_RECEIVER消息

[code]

package com.lizongbo..server.handlers;

import org.apache.mina.common.*;
import com.lizongbo.smpp.server.*;
import ie.omk.smpp.*;
import ie.omk.smpp.message.*;
import ie.omk.smpp.message.tlv.*;
import ie.omk.smpp.util.*;
import ie.omk.smpp.version.*;

/**
*
* <p>Title: BindReceiver Handler</p>
*
* <p>Description: smpp BIND_RECEIVER</p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: http://618119.com </p>
*
* @author lizongbo
* @version 1.0
*/
public class BindReceiverHandler
implements SMPPPacketHandler {
public void process(IoSession session, SMPPPacket packet) throws
BadCommandIDException {
BindReceiver msg = (BindReceiver) packet;
System.out.println(“sysId=” + msg.getSystemId());
System.out.println(“password=” + msg.getPassword());
//在这里判断账号和密码是否正确
System.out.println(“sysType=” + msg.getSystemType());
System.out.println(“interfaceVer=” + msg.getInterfaceVersion());
System.out.println(“addrTon=” + msg.getAddressTon());
System.out.println(“addrNpi=” + msg.getAddressNpi());
System.out.println(“addressRange=” + msg.getAddressRange());

BindReceiverResp res = (BindReceiverResp) PacketFactory.
newInstance(SMPPPacket.BIND_RECEIVER_RESP);
res.setCommandStatus(0);
res.setSequenceNum(packet.getSequenceNum());
res.setSystemId(“.618119.com”);
res.setOptionalParameter(Tag.SC_INTERFACE_VERSION,
SMPPVersion.getDefaultVersion().getVersionID());
session.write(res);
}

}

[/code]

2.处理BIND_TRANSMITTER消息

[code]

package com.lizongbo.smpp.server.handlers;

import org.apache.mina.common.*;
import com.lizongbo.smpp.server.*;
import ie.omk.smpp.*;
import ie.omk.smpp.message.*;
import ie.omk.smpp.message.tlv.*;
import ie.omk.smpp.util.*;
import ie.omk.smpp.version.*;
/**
*
* <p>Title: BindTransmitter Handler</p>
*
* <p>Description: smpp BIND_TRANSMITTER</p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: http://618119.com </p>
*
* @author lizongbo
* @version 1.0
*/
public class BindTransmitterHandler
implements SMPPPacketHandler {
public void process(IoSession session, SMPPPacket packet) throws
BadCommandIDException {
BindTransmitter msg = (BindTransmitter) packet;
System.out.println(“sysId=” + msg.getSystemId());
System.out.println(“password=” + msg.getPassword());
System.out.println(“sysType=” + msg.getSystemType());
System.out.println(“interfaceVer=” + msg.getInterfaceVersion());
System.out.println(“addrTon=” + msg.getAddressTon());
System.out.println(“addrNpi=” + msg.getAddressNpi());
System.out.println(“addressRange=” + msg.getAddressRange());

BindTransmitterResp res = (BindTransmitterResp) PacketFactory.
newInstance(SMPPPacket.BIND_TRANSMITTER_RESP);
res.setCommandStatus(msg.getCommandStatus());
res.setSequenceNum(packet.getSequenceNum());
res.setSystemId(“smsc.618119.com”);
res.setOptionalParameter(Tag.SC_INTERFACE_VERSION,
SMPPVersion.getDefaultVersion().getVersionID());
session.write(res);
}

}
[/code]

3.处理DELIVER_SM_RESP,SUBMIT_SM,UNBIND消息的代码片断.

[code]

public void process(IoSession session, SMPPPacket packet) throws
BadCommandIDException {
DeliverSMResp msg = (DeliverSMResp) packet;
System.out.println(“收到确认的消息编号:” + msg.getMessageId());
}

public void process(IoSession session, SMPPPacket packet) throws
BadCommandIDException {
SubmitSM msg = (SubmitSM) packet;

System.out.println(“serviceType=” + msg.getServiceType());
System.out.println(“source=” + msg.getSource());
System.out.println(“destination=” + msg.getDestination());
System.out.println(“esmClass=” + msg.getEsmClass());
System.out.println(“protocolID=” + msg.getProtocolID());
System.out.println(“priority=” + msg.getPriority());
System.out.println(“delivery=” + msg.getDeliveryTime());

System.out.println(“expiryTime=” + msg.getExpiryTime());
System.out.println(“registered=” + msg.getRegistered());
System.out.println(“replaceIfPresent=” + msg.getReplaceIfPresent());
System.out.println(“dataCoding=” + msg.getDataCoding());
System.out.println(“defaultMsg=” + msg.getDefaultMsg());
System.out.println(“message=” + new String(msg.getMessage()));
SubmitSMResp res = (SubmitSMResp) PacketFactory.
newInstance(SMPPPacket.SUBMIT_SM_RESP);
res.setCommandStatus(0);
res.setSequenceNum(packet.getSequenceNum());
res.setMessageId(“11233”);
session.write(res);
}

public void process(IoSession session, SMPPPacket packet) throws
BadCommandIDException {
Unbind msg = (Unbind) packet;
UnbindResp res = (UnbindResp) PacketFactory.
newInstance(SMPPPacket.UNBIND_RESP);
res.setCommandStatus(0);
res.setSequenceNum(packet.getSequenceNum());
session.write(res);
}

[/code]

一条评论 »

  1. […] 用Spring,smppapi,apache mina, commons ssl快速实现安全的smpp smsc (五) 作者:lizongbo 发表于:8:43 am. 星期四, 12月 13th, 2007 版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明。 http://618119.com/archives/2007/12/13/45.html 接上一篇:  http://618119.com/archives/2007/12/06/39.html […]

    Pingback by » 用Spring,smppapi,apache mina, commons ssl快速实现安全的smpp smsc (五) -- lizongbo at 618119.com — 2007年12月13日 @ 08:43

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress