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

📄 smproxy30.java

📁 移动CMPP的网关,JAVA又一实现,非常完整的代码.
💻 JAVA
字号:
/*
 * Created on Mar 17, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.grail.smproxy;

import java.io.IOException;
import java.util.Map;

import com.grail.comm.cmpp.CMPP30Connection;
import com.grail.comm.cmpp.CMPP30Transaction;
import com.grail.comm.cmpp.message.CMPP30DeliverMessage;
import com.grail.comm.cmpp.message.CMPP30DeliverRepMessage;
import com.grail.comm.cmpp.message.CMPPMessage;
import com.grail.util.Args;

/**
 * @author eclipse
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class SMProxy30
{

    private CMPP30Connection conn;

    public SMProxy30(Map args)
    {
        this(new Args(args));
    }

    public SMProxy30(Args args)
    {
        conn = new CMPP30Connection(args);
        conn.addEventListener(new CMPP30EventAdapter(this));
        conn.waitAvailable();
        if(!conn.available())
            throw new IllegalStateException(conn.getError());
        else
            return;
    }

    public CMPPMessage send(CMPPMessage message)
        throws IOException
    {
        if(message == null)
            return null;
        CMPP30Transaction t = (CMPP30Transaction)conn.createChild();
        try
        {
            t.send(message);
            t.waitResponse();
            CMPPMessage rsp = t.getResponse();
            CMPPMessage cmppmessage = rsp;
            return cmppmessage;
        }
        finally
        {
            t.close();
        }
    }

    public void onTerminate()
    {
    }

    public CMPPMessage onDeliver(CMPP30DeliverMessage msg)
    {
        return new CMPP30DeliverRepMessage(msg.getMsgId(), 0);
    }

    public void close()
    {
        conn.close();
    }

    public CMPP30Connection getConn()
    {
        return conn;
    }

    public String getConnState()
    {
        return conn.getError();
    }
}

⌨️ 快捷键说明

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