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

📄 sgipsmproxy.java

📁 华为java接口反编译结果!其中包含其所有接口实现过程
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   SGIPSMProxy.java

package com.huawei.smproxy;

import com.huawei.insa2.comm.PLayer;
import com.huawei.insa2.comm.sgip.*;
import com.huawei.insa2.comm.sgip.message.*;
import com.huawei.insa2.util.Args;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

// Referenced classes of package com.huawei.smproxy:
//            SGIPEventAdapter

public class SGIPSMProxy
    implements SSEventListener
{

    private SGIPConnection conn;
    private SSListener listener;
    private Args args;
    private HashMap serconns;
    private int src_nodeid;

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

    public SGIPSMProxy(Args args)
    {
        this.args = args;
        src_nodeid = args.get("source-addr", 0);
    }

    public synchronized boolean connect(String loginName, String loginPass)
    {
        boolean result = true;
        if(loginName != null)
            args.set("login-name", loginName.trim());
        if(loginPass != null)
            args.set("login-pass", loginPass.trim());
        conn = new SGIPConnection(args, true, null);
        conn.addEventListener(new SGIPEventAdapter(this, conn));
        conn.waitAvailable();
        if(!conn.available())
        {
            result = false;
            throw new IllegalStateException(conn.getError());
        } else
        {
            return result;
        }
    }

    public synchronized void startService(String localhost, int localport)
    {
        if(listener != null)
            return;
        try
        {
            listener = new SSListener(localhost, localport, this);
            listener.beginListen();
        }
        catch(Exception exception) { }
    }

    public synchronized void stopService()
    {
        if(listener == null)
            return;
        listener.stopListen();
        if(serconns != null)
        {
            SGIPConnection conn;
            for(Iterator iterator = serconns.keySet().iterator(); iterator.hasNext(); conn.close())
            {
                String addr = (String)iterator.next();
                conn = (SGIPConnection)serconns.get(addr);
            }

            serconns.clear();
        }
    }

    public synchronized void onConnect(Socket socket)
    {
        String peerIP = socket.getInetAddress().getHostAddress();
        int port = socket.getPort();
        if(serconns == null)
            serconns = new HashMap();
        SGIPConnection conn = new SGIPConnection(args, false, serconns);
        conn.addEventListener(new SGIPEventAdapter(this, conn));
        conn.attach(args, socket);
        serconns.put(new String(String.valueOf(peerIP) + String.valueOf(port)), conn);
    }

    public SGIPMessage send(SGIPMessage message)
        throws IOException
    {
        if(message == null)
            return null;
        SGIPTransaction t = (SGIPTransaction)conn.createChild();
        t.setSPNumber(src_nodeid);
        Date nowtime = new Date();
        SimpleDateFormat dateFormat = new SimpleDateFormat("MMddHHmmss");
        String tmpTime = dateFormat.format(nowtime);
        Integer timestamp = new Integer(tmpTime);
        t.setTimestamp(timestamp.intValue());
        try
        {
            t.send(message);
            t.waitResponse();
            SGIPMessage rsp = t.getResponse();
            SGIPMessage sgipmessage = rsp;
            return sgipmessage;
        }
        finally
        {
            t.close();
        }
    }

    public void onTerminate()
    {
    }

    public SGIPMessage onDeliver(SGIPDeliverMessage msg)
    {
        return new SGIPDeliverRepMessage(0);
    }

    public SGIPMessage onReport(SGIPReportMessage msg)
    {
        return new SGIPReportRepMessage(0);
    }

    public SGIPMessage onUserReport(SGIPUserReportMessage msg)
    {
        return new SGIPUserReportRepMessage(0);
    }

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

    public SGIPConnection getConn()
    {
        return conn;
    }

    public String getConnState()
    {
        if(conn != null)
            return conn.getError();
        else
            return "尚未建立连接";
    }
}

⌨️ 快捷键说明

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