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

📄 cmpp30eventadapter.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 com.grail.comm.cmpp.CMPP30Connection;
import com.grail.comm.cmpp.CMPP30Transaction;
import com.grail.comm.cmpp.message.CMPP30DeliverMessage;
import com.grail.comm.cmpp.message.CMPPActiveRepMessage;
import com.grail.comm.cmpp.message.CMPPMessage;
import com.grail.comm.cmpp.message.CMPPTerminateRepMessage;
import com.grail.comm.core.PEventAdapter;
import com.grail.comm.core.PException;
import com.grail.comm.core.PLayer;

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

    private SMProxy30 smProxy;
    private CMPP30Connection conn;

    public CMPP30EventAdapter(SMProxy30 smProxy)
    {
        this.smProxy = null;
        conn = null;
        this.smProxy = smProxy;
        conn = smProxy.getConn();
    }

    public void childCreated(PLayer child)
    {
        CMPP30Transaction t = (CMPP30Transaction)child;
        CMPPMessage msg = t.getResponse();
        CMPPMessage resmsg = null;
        if(msg.getCommandId() == 2)
        {
            resmsg = new CMPPTerminateRepMessage();
            smProxy.onTerminate();
        } else
        if(msg.getCommandId() == 8)
            resmsg = new CMPPActiveRepMessage(0);
        else
        if(msg.getCommandId() == 5)
        {
            CMPP30DeliverMessage tmpmes = (CMPP30DeliverMessage)msg;
            resmsg = smProxy.onDeliver(tmpmes);
        } else
        {
            t.close();
        }
        if(resmsg != null)
        {
            try
            {
                t.send(resmsg);
            }
            catch(PException e)
            {
                e.printStackTrace();
            }
            t.close();
        }
        if(msg.getCommandId() == 2)
            conn.close();
    }
}

⌨️ 快捷键说明

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