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

📄 recvthread.java

📁 短信平台CMPP30 的JAVA程序,(含SQL数据库)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// 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:   RecvThread.java

package com.SGIP12.sgiputil;

import com.SGIP12.sgipdata.*;
import com.log.CTime;
import java.io.*;
import java.net.*;
import javax.swing.JTextArea;

// Referenced classes of package com.SGIP12.sgiputil:
//            SGIPPacket, SGIPConfig, SGIPLog, SGIPQueue

public class RecvThread extends Thread
{

    private UnbindResp Unresp;
    private Bind active;
    private SGIP_Command command;
    private Deliver deliver;
    private DeliverResp deliverresp;
    private int destroy;
    private int initTimes;
    private InputStream input;
    private int localPort;
    private String localPwd;
    private String localUserName;
    private String logFile;
    private OutputStream output;
    private JTextArea packetArea;
    private SGIPQueue recvQueue;
    private Report report;
    private ReportResp reportresp;
    private BindResp resp;
    private int result;
    private boolean running;
    private SGIPQueue sendQueue;
    private ServerSocket serversocket;
    private SGIPPacket sgipPacket;
    private Socket so;
    private JTextArea stateArea;
    private boolean stopFlag;
    private Unbind term;
    private int timeout;
    private SGIP_Command tmpCMD;
    private Userrpt userrpt;
    private UserrptResp userrptresp;

    public RecvThread(SGIPConfig conf, SGIPQueue sendQ, SGIPQueue recvQ)
    {
        serversocket = null;
        timeout = 10000;
        so = null;
        localPort = 0;
        localUserName = null;
        localPwd = null;
        output = null;
        input = null;
        command = null;
        tmpCMD = null;
        active = null;
        term = null;
        resp = null;
        Unresp = null;
        deliver = null;
        deliverresp = null;
        report = null;
        reportresp = null;
        userrpt = null;
        userrptresp = null;
        stateArea = null;
        packetArea = null;
        running = true;
        stopFlag = false;
        destroy = 0;
        initTimes = 0;
        localPort = conf.getLocalPort();
        localUserName = conf.getLocalUser();
        localPwd = conf.getLocalPwd();
        logFile = "Recv";
        sendQueue = sendQ;
        recvQueue = recvQ;
        if(stateArea != null)
            stateArea.append(CTime.getStringDate() + " SGIP12模块服务器端正在启动!\n\n");
    }

    public void Exit()
    {
        try
        {
            if(serversocket != null)
                serversocket.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        running = false;
    }

    public void ReWork()
    {
        stopFlag = false;
    }

    public void SetTextArea(JTextArea sa, JTextArea pa)
    {
        stateArea = sa;
        packetArea = pa;
    }

    public void StopWork()
    {
        if(stateArea != null)
            stateArea.append(CTime.getStringDate() + " SGIP12模块服务器端停止!\n\n");
        stopFlag = true;
    }

    public int getDestory()
    {
        return destroy;
    }

    public void run()
    {
_L2:
        if(!stopFlag)
            break MISSING_BLOCK_LABEL_89;
        if(serversocket != null && so != null)
        {
            so.close();
            serversocket.close();
        }
        Thread.sleep(1000L);
        try
        {
            Thread.sleep(10L);
            if(so != null)
                so.close();
        }
        catch(Exception s)
        {
            System.out.println(s.toString());
        }
        continue; /* Loop/switch isn't completed */
        if(serversocket == null || serversocket.isClosed())
        {
            serversocket = new ServerSocket(localPort);
            serversocket.setSoTimeout(timeout);
        }
        initTimes++;
        if(stateArea != null && initTimes == 1)
            stateArea.append(CTime.getStringDate() + " SGIP12模块服务器端初始化成功!\n\n");
        if(serversocket.isClosed())
        {
            try
            {
                Thread.sleep(10L);
                if(so != null)
                    so.close();
            }
            catch(Exception s)
            {
                System.out.println(s.toString());
            }
            continue; /* Loop/switch isn't completed */
        }
        so = serversocket.accept();
        input = so.getInputStream();
        output = so.getOutputStream();
        command = new SGIP_Command();
        boolean loop = true;
        while(loop) 
        {
            tmpCMD = command.read(input);
            switch(command.getCommandID())
            {
            case 1: // '\001'
                active = (Bind)tmpCMD;
                result = active.readbody();
                if(packetArea != null)
                {
                    packetArea.append(CTime.getStringDate() + "--SGIP12--Bind: (SMG->SP)\n");
                    packetArea.append("TotalLength: " + active.getTotalLength() + "\n");
                    packetArea.append("CommandID: " + active.getCommandID() + "\n");
                    packetArea.append("SequenceID_1: " + active.getSeqno_1() + "\n");
                    packetArea.append("SequenceID_2: " + active.getSeqno_2() + "\n");
                    packetArea.append("SequenceID_3: " + active.getSeqno_3() + "\n");
                    packetArea.append("LoginType: " + active.GetLoginType() + "\n");
                    packetArea.append("LoginName: " + active.GetLoginName().trim() + "\n");
                    packetArea.append("LoginPassword: " + active.GetLoginPassword().trim() + "\n\n");
                }
                System.out.println(tmpCMD.getTotalLength());
                System.out.println(tmpCMD.getCommandID());
                System.out.println(tmpCMD.getSeqno_1());
                System.out.println(tmpCMD.getSeqno_2());
                System.out.println(tmpCMD.getSeqno_3());
                System.out.println(active.GetLoginType());
                System.out.println(active.GetLoginName().trim());
                System.out.println(active.GetLoginPassword().trim());
                resp = new BindResp(tmpCMD.getMsgHead());
                resp.SetResult(result);
                if(active.GetLoginType() != 1)
                {
                    resp.SetResult(4);
                    SGIPLog.WriteLog(-2, "收到Bind包:登录类型错,logintype字段出错", logFile);
                } else
                {
                    if(!localUserName.equals(active.GetLoginName().trim()) || !localPwd.equals(active.GetLoginPassword().trim()))
                    {
                        resp.SetResult(1);
                        SGIPLog.WriteLog(-2, "收到Bind包:非法登录,如登录名、口令出错、登录名与口令不符等", logFile);
                    }
                    resp.write(output);
                    if(packetArea != null)
                    {
                        packetArea.append(CTime.getStringDate() + "--SGIP12--BindResp: (SP->SMG)\n");
                        packetArea.append("TotalLength: " + resp.getTotalLength() + "\n");
                        packetArea.append("CommandID: " + resp.getCommandID() + "\n");
                        packetArea.append("SequenceID_1: " + resp.getSeqno_1() + "\n");
                        packetArea.append("SequenceID_2: " + resp.getSeqno_2() + "\n");
                        packetArea.append("SequenceID_3: " + resp.getSeqno_3() + "\n");
                        packetArea.append("Result: " + resp.GetResult() + "\n\n");
                    }
                }
                break;

            case 2: // '\002'
                term = (Unbind)tmpCMD;
                if(packetArea != null)
                {
                    packetArea.append(CTime.getStringDate() + "--SGIP12--Unbind: (SMG->SP)\n");
                    packetArea.append("TotalLength: " + term.getTotalLength() + "\n");
                    packetArea.append("CommandID: " + term.getCommandID() + "\n");
                    packetArea.append("SequenceID_1: " + term.getSeqno_1() + "\n");
                    packetArea.append("SequenceID_2: " + term.getSeqno_2() + "\n");

⌨️ 快捷键说明

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