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

📄 clusterauthpacket.java

📁 很多人都在开发的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.out;

import java.nio.ByteBuffer;

import edu.tsinghua.lumaqq.qq.PacketParseException;
import edu.tsinghua.lumaqq.qq.QQ;
import edu.tsinghua.lumaqq.qq.Utils;

/**
 * <pre>
 * 发送认证信息的包,格式为:
 * 1. 头部
 * 2. 群命令类型,1字节,认证消息是0x8
 * 3. 群内部ID,4字节
 * 4. 认证消息的类型,比如是请求,拒绝还是同意,1字节
 * 5. 发出请求的QQ号,4字节
 * 6. 附加消息的长度,1字节
 * 7. 附加消息
 * 8. 尾部
 * </pre>
 * 
 * @author 马若劼
 */
public class ClusterAuthPacket extends ClusterCommandPacket {
	public int type;
	private String message;
	
    /**
     * 构造函数
     */
    public ClusterAuthPacket() {
        super();
		this.subCommand = QQ.QQ_CLUSTER_CMD_JOIN_CLUSTER_AUTH;
		this.message = "";
    }

    /**
     * @param buf
     * @param length
     * @throws PacketParseException
     */
    public ClusterAuthPacket(ByteBuffer buf, int length)
            throws PacketParseException {
        super(buf, length);
    }
    
    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.qq.packets.OutPacket#putBody(java.nio.ByteBuffer)
     */
    protected void putBody(ByteBuffer buf) {
		// 群命令类型
		buf.put(subCommand);
		// 群内部ID
		buf.putInt(clusterId);
		// 认证消息类型
		buf.put((byte)type);
		// 用户QQ号
		buf.putInt(user.getQQ());
		// 附加消息长度
		byte[] b = message.getBytes();
		buf.put((byte)(b.length & 0xFF));
		// 附加消息
		buf.put(b);
    }
    
    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.qq.packets.OutPacket#parseBody(java.nio.ByteBuffer)
     */
    protected void parseBody(ByteBuffer buf) throws PacketParseException {
        subCommand = buf.get();
        clusterId = buf.getInt();
        type = buf.get() & 0xFF;
        buf.getInt();
        buf.get();
        message = Utils.getString(buf);
    }
	
	/**
	 * @return Returns the message.
	 */
	public String getMessage() {
		return message;
	}
	
	/**
	 * @param message The message to set.
	 */
	public void setMessage(String message) {
		this.message = message;
	}
	
	/**
	 * @return Returns the type.
	 */
	public int getType() {
		return type;
	}
	
	/**
	 * @param type The type to set.
	 */
	public void setType(int type) {
		this.type = type;
	}
}

⌨️ 快捷键说明

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