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

📄 sendsmsreplypacket.java

📁 java写的qq代码实现qq的部分功能
💻 JAVA
字号:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 luma <stubma@163.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.tsinghua.lumaqq.qq.packets.in;

import java.nio.ByteBuffer;

import edu.tsinghua.lumaqq.qq.PacketParseException;
import edu.tsinghua.lumaqq.qq.Util;
import edu.tsinghua.lumaqq.qq.beans.QQUser;
import edu.tsinghua.lumaqq.qq.packets.BasicInPacket;

/**
 * <pre>
 * 发送短消息的回复包,格式为:
 * 1. 头部
 * 2. 未知1字节
 * 3. 四个未知字节,全0
 * 4. 未知1字节
 * 5. 回复消息长度,1字节
 * 6. 回复消息内容,可能以0结尾,也可能不以0结尾,所以前面的消息长度并不可靠,还是应该以分隔符来判断
 * 7. 分隔符,1字节,0x01
 * 8. 接受者QQ号或者接受者手机号码。如果是QQ号,4个字节,如果是手机号码,最大18字节
 * 9. 如果是手机号码,则这里还有一个未知字节,0x00
 * 10. 回复码,如果是QQ号码,则回复码是1个字节,如果是手机号码,回复码是2个字节
 * 11. 如果是QQ号码,未知的1字节,如果是手机号码,未知的2字节
 * 11. 尾部
 * </pre>
 * 
 * @author 马若劼
 */
public class SendSMSReplyPacket extends BasicInPacket {
    private static final byte DELIMIT = 0x01;
    
    /*
     * true表示这个包是发向绑定手机用户的回复包,这个和协议无关,是我自己定义的,所以
     * 不一定是正确的。但是至少是work的
     */ 
    public boolean toBindUser;
    
    public String replyMessage;
    
    // 用在1类回复中
    public byte replyCode_1;
    public int recevier;
    
    // 用在2类回复中
    public char replyCode_2;
    public String mobileNumber;
    
    /**
     * @param buf
     * @param length
     * @throws PacketParseException
     */
    public SendSMSReplyPacket(ByteBuffer buf, int length, QQUser user) throws PacketParseException {
        super(buf, length, user);
    }
    
    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.qq.packets.InPacket#getPacketName()
     */
    public String getPacketName() {
        return "Send SMS Reply Packet";
    }

    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.qq.packets.InPacket#parseBody(java.nio.ByteBuffer)
     */
    protected void parseBody(ByteBuffer buf) throws PacketParseException {
        // 未知1字节
        buf.get();
        // 四个未知字节,全0
        buf.getInt();
        // 未知1字节
        buf.get();
        // 回复消息长度,1字节
        buf.get();
        // 6. 回复消息内容
        replyMessage = Util.getString(buf, DELIMIT);
        
        if(buf.remaining() > 6) {
            toBindUser = false;
            
            // 接收者手机号
            mobileNumber = Util.getString(buf, (byte)0, 18);
            
            // 未知1字节
            buf.get();
            
            // 回复码
            replyCode_2 = buf.getChar();
        } else {
            toBindUser = true;
            
            //  接受者QQ号,4字节
	        recevier = buf.getInt();     
	        // 回复码,1字节
	        replyCode_1 = buf.get();            
        }
    }
}

⌨️ 快捷键说明

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