?? clustercreatepacket.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字節,創建是0x01
* 3. 群的類型,固定還是臨時,1字節
* 4. 是否需要認證,1字節
* 5. 未知的2字節,0x0000
* 6. 群的分類,2字節。2003中有提供了四個分類,比如同學,朋友,這個字段就是分類的序號,
* 估計自己隨便搞個分類也沒有問題
* 7. 群名稱長度,1字節
* 8. 群名稱
* 9. 未知的2字節,0x0000
* 10. 群聲明長度,1字節
* 11. 群聲明
* 12. 群描述長度,1字節
* 13. 群描述
* 14. 群現有成員的QQ號列表,每個QQ號4字節
* 15. 尾部
* </pre>
*
* @author 馬若劼
*/
public class ClusterCreatePacket extends ClusterCommandPacket {
private byte type;
private byte authType;
private char category;
private String name;
private String notice;
private String description;
private int[] members;
/**
* 構造函數
*/
public ClusterCreatePacket() {
super();
this.subCommand = QQ.QQ_CLUSTER_CMD_CREATE_CLUSTER;
this.type = QQ.QQ_CLUSTER_TYPE_PERMANENT;
this.authType = QQ.QQ_CLUSTER_NEED_AUTH;
}
/**
* @param buf
* @param length
* @throws PacketParseException
*/
public ClusterCreatePacket(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);
// 群類型
buf.put(type);
// 認證類型
buf.put(authType);
// 未知的2字節
buf.putChar((char)0);
// 群的分類
buf.putChar(category);
// 群名稱長度和群名稱
byte[] b = name.getBytes();
buf.put((byte)(b.length & 0xFF));
buf.put(b);
// 未知的2字節
buf.putChar((char)0);
// 群聲明長度和群聲明
b = notice.getBytes();
buf.put((byte)(b.length & 0xFF));
buf.put(b);
// 群描述長度和群描述
b = description.getBytes();
buf.put((byte)(b.length & 0xFF));
buf.put(b);
// 群中的好友
for(int i = 0; i < members.length; i++)
buf.putInt(members[i]);
}
/* (non-Javadoc)
* @see edu.tsinghua.lumaqq.qq.packets.OutPacket#parseBody(java.nio.ByteBuffer)
*/
protected void parseBody(ByteBuffer buf) throws PacketParseException {
subCommand = buf.get();
type = buf.get();
authType = buf.get();
buf.getChar();
category = buf.getChar();
name = Utils.getString(buf, buf.get() & 0xFF);
buf.getChar();
notice = Utils.getString(buf, buf.get() & 0xFF);
description = Utils.getString(buf, buf.get() & 0xFF);
int m = buf.remaining() / 4;
members = new int[m];
for(int i = 0; i < m; i++)
members[i] = buf.getInt();
}
/**
* @return Returns the authType.
*/
public byte getAuthType() {
return authType;
}
/**
* @param authType The authType to set.
*/
public void setAuthType(byte authType) {
this.authType = authType;
}
/**
* @return Returns the description.
*/
public String getDescription() {
return description;
}
/**
* @param description The description to set.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return Returns the members.
*/
public int[] getMembers() {
return members;
}
/**
* @param members The members to set.
*/
public void setMembers(int[] members) {
this.members = members;
}
/**
* @return Returns the name.
*/
public String getName() {
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @return Returns the notice.
*/
public String getNotice() {
return notice;
}
/**
* @param notice The notice to set.
*/
public void setNotice(String notice) {
this.notice = notice;
}
/**
* @return Returns the type.
*/
public byte getType() {
return type;
}
/**
* @param type The type to set.
*/
public void setType(byte type) {
this.type = type;
}
/**
* @return Returns the category.
*/
public char getCategory() {
return category;
}
/**
* @param category The category to set.
*/
public void setCategory(char category) {
this.category = category;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -