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

📄 cmpppacket.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:   cmppPacket.java

package com.aspire.cmppApi;

import java.io.*;

// Referenced classes of package com.aspire.cmppApi:
//            cmppCommon, cmppSocket

public class cmppPacket
{

    private int TotalLength;
    private int CommandID;
    private int SequenceId;
    private byte bodybytes[];
    private byte headbytes[];
    public cmppSocket conn;
    public static final int CMPP_Connect = 1;
    public static final int CMPP_Connect_REP = 0x80000001;
    public static final int CMPP_Terminate = 2;
    public static final int CMPP_Terminate_REP = 0x80000002;
    public static final int CMPP_Submit = 4;
    public static final int CMPP_Submit_REP = 0x80000004;
    public static final int CMPP_Deliver = 5;
    public static final int CMPP_Deliver_REP = 0x80000005;
    public static final int CMPP_Query = 6;
    public static final int CMPP_Query_REP = 0x80000006;
    public static final int CMPP_Cancel = 7;
    public static final int CMPP_Cancel_REP = 0x80000007;
    public static final int CMPP_Active_Test = 8;
    public static final int CMPP_Active_Test_REP = 0x80000008;

    public cmppPacket(cmppSocket cmppsocket)
    {
        TotalLength = 0;
        CommandID = 0;
        SequenceId = 0;
        conn = cmppsocket;
    }

    public int getCommandID()
    {
        return CommandID;
    }

    public byte[] getPacketBody()
    {
        return bodybytes;
    }

    public int getSequenceId()
    {
        return SequenceId;
    }

    public int getTotalLength()
    {
        return TotalLength;
    }

    public int readPacket()
    {
        int i = -6;
		try
		{
			int j = 0;
			headbytes = new byte[12];
		//	System.out.println("可用的数据流"+conn.din.available());
			int f =conn.din.available();
			if(f>0)
			{
				synchronized(conn)
				{
					int k =0;
					for(; j < 12; j += k)
					{
					
				
						k = conn.din.read(headbytes, j, 12 - j);
					
						if(k == -1)
						{
							byte byte0 = -6;
							return byte0;
						}
					
					}

					byte abyte2[] = new byte[4];
					cmppCommon.BytesCopy(headbytes, abyte2, 0, 3, 0);
					TotalLength = cmppCommon.Bytes4ToInt(abyte2);
					int l = TotalLength - 12;
					j = 0;
					bodybytes = new byte[l];
					int i1;
					for(; j < l; j += i1)
					{
						i1 = conn.din.read(bodybytes, j, l - j);
						if(i1 < 0)
						{
							byte byte1 = -6;
							return byte1;
						}
					}

				}
			
			
				byte abyte0[] = new byte[4];
				cmppCommon.BytesCopy(headbytes, abyte0, 4, 7, 0);
				CommandID = cmppCommon.Bytes4ToInt(abyte0);
				byte abyte1[] = new byte[4];
				cmppCommon.BytesCopy(headbytes, abyte1, 8, 11, 0);
				SequenceId = cmppCommon.Bytes4ToInt(abyte1);
				i = SequenceId;
			}
			else
			{
			i =-1;
			}
		}
		catch(InterruptedIOException interruptedioexception)
		{
			i = -6;
			System.out.println("Read packet timeout...");
			System.out.println(interruptedioexception.toString());
			return -6;
		}
		catch(IOException ioexception)
		{
			i = -6;
			System.out.println("Read packet failed...");
			System.out.println(ioexception.toString());
			return i;
		}
        return i;
    }
}

⌨️ 快捷键说明

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