天天看點

Logica SMPP 源代碼修改

Logica SMPP API在使用中,存在一些問題,列舉如下:

1. 支援長短信,在SubmitSM.java類中加入方法setShortMessageData

/**
     * added by zcg 2012-01-18
     * 處理長短信
     * 
     * @param buffer
     * @throws WrongLengthOfStringException
     */
    public void setShortMessageData(ByteBuffer buffer) throws WrongLengthOfStringException{
    	try{
    		this.shortMessage.setData(buffer);
    	} catch (Exception e) {
    		if ((e instanceof WrongLengthOfStringException)) {
    			throw ((WrongLengthOfStringException)e);
    		}
    		throw new WrongLengthOfStringException();
    	}
    	setSmLength((short)this.shortMessage.getLength());
    }
           

2. 支援SME用戶端綁定指定端口,修改TCPIPConnection.java類open方法

// start, modified by zcg 2012-10-08
                	if(localAddress != null && localPort != 0){
                		SocketAddress bindPoint = new InetSocketAddress(localAddress, localPort);
    					socket = new Socket();
    					socket.setReuseAddress(true);
    					socket.bind(bindPoint);

    					SocketAddress endPoint = new InetSocketAddress(address, port);
    					socket.connect(endPoint, timeout);
                	}else{
                		socket = new Socket(address, port);
                	}
					// end, modified by zcg 2012-10-08