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

📄 getfriendonlinepacket.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.packets.OutPacket;

/**
 * <pre>
 * 获取在线好友列表的请求包,格式为
 * 1. 头部
 * 2. 1个字节,只有值为0x02或者0x03时服务器才有反应,不然都是返回0xFF
 *    经过初步的试验,发现3得到的好友都是一些系统服务,号码比如72000001到72000013,
 *    就是那些移动QQ,会员服务之类的;而2是用来得到好友的
 * 3. 1个字节,得到好友列表的位置,也就是position,这个position的含义和
 *    GetFriendListPacket中的position相同,只不过这个position单位是1 byte,
 *    当然也有可能GetFriendListPacket中的position也是1 byte,不好说
 * 4. 1个未知字节,设成0
 * 5. 2个未知字节,设成0
 * 6. 尾部
 * </pre>
 *
 * @author 马若劼
 */
public class GetFriendOnlinePacket extends OutPacket {
	// position,缺省设成0
	private byte startPosition;
	
	/**
	 * 构造函数
	 */
	public GetFriendOnlinePacket() {
	    super(QQ.QQ_CMD_GET_FRIEND_ONLINE, true);
	    startPosition = QQ.QQ_FRIEND_ONLINE_LIST_POSITION_START;
	}
	
    /**
     * @param buf
     * @param length
     * @throws PacketParseException
     */
    public GetFriendOnlinePacket(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((byte)0x2);
        buf.put(startPosition);
        buf.put((byte)0);
        buf.put((byte)0);
        buf.put((byte)0);        
    }
    
    /* (non-Javadoc)
     * @see edu.tsinghua.lumaqq.qq.packets.OutPacket#parseBody(java.nio.ByteBuffer)
     */
    protected void parseBody(ByteBuffer buf) throws PacketParseException {
        buf.get();
        startPosition = buf.get();
    }
	
	/**
	 * @return Returns the position.
	 */
	public byte getStartPosition() {
		return startPosition;
	}
	
	/**
	 * @param position The position to set.
	 */
	public void setStartPosition(byte position) {
		this.startPosition = position;
	}
}

⌨️ 快捷键说明

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