?? clusterauthpacket.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 + -