📄 sendimpacket.java
字号:
while((j = message.indexOf((char)QQ.QQ_TAG_DEFAULT_FACE, i)) != -1) {
String sub = message.substring(i, j);
if(!sub.equals("")) {
b = Util.getBytes(sub);
buf.put(b);
}
buf.put(QQ.QQ_TAG_DEFAULT_FACE);
buf.put((byte)(message.charAt(j + 1) & 0xFF));
i = j + 2;
}
if(i < message.length()) {
String sub = message.substring(i);
b = Util.getBytes(sub);
buf.put(b);
}
// 最后一个分片时追加空格
if(fragmentSequence == totalFragments - 1)
buf.put((byte)0x20);
// 消息尾部,字体修饰属性
fontStyle.writeBean(buf);
}
/**
* 调试方法,从QQ的抓包中里面解析出内容,看看有没有问题,实际中请勿使用
*/
/* public byte[] forDebug(byte[] packetBuf) {
// 提取加密内容
byte[] buf = new byte[packetBuf.length - 12];
System.arraycopy(packetBuf, 11, buf, 0, buf.length);
// 解密
buf = crypter.decrypt(buf, user.getSessionKey());
// 创建流
ByteArrayInputStream bais = new ByteArrayInputStream(buf);
DataInputStream dis = new DataInputStream(bais);
try {
log.debug("接收者: " + dis.readInt());
log.debug("发送者: " + dis.readInt());
log.debug("发送者QQ版本: " + Utils.getClientString(dis.readChar()) );
log.debug("接收者: " + dis.readInt());
log.debug("发送者: " + dis.readInt());
log.debug("跳过16字节MD5");
dis.skipBytes(16);
log.debug("消息类型: " + Util.getIMTypeString(dis.readChar()));
log.debug("消息序号: " + (int)dis.readChar());
log.debug("发送时间: " + new Date((long)dis.readInt() * 1000L).toString());
log.debug("跳过1字节");
dis.skipBytes(1);
log.debug("发送者头像: " + (dis.readByte() & 0xFF));
log.debug("跳过8字节");
dis.skipBytes(8);
log.debug("消息回复类型: " + Util.getIMReplyType(dis.readByte()));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
while(true) {
byte b = dis.readByte();
if(b == 0) break;
dos.writeByte(b);
}
message = new String(baos.toByteArray(), QQ.QQ_CHARSET_DEFAULT);
log.debug("消息正文: " + message);
dos.close();
byte flag = dis.readByte();
log.debug("字体大小: " + (int)(flag & 0x1F));
log.debug("粗体: " + ((flag & 0x20) != 0));
log.debug("斜体: " + ((flag & 0x40) != 0));
log.debug("下划线: " + ((flag & 0x80) != 0));
log.debug("红: " + (dis.readByte() & 0xFF));
log.debug("绿: " + (dis.readByte() & 0xFF));
log.debug("蓝: " + (dis.readByte() & 0xFF));
log.debug("跳过1字节");
dis.skipBytes(1);
log.debug("消息编码: " + Util.getEncodingString(dis.readChar()));
byte[] f = new byte[dis.available()];
dis.read(f);
log.debug("字体: " + new String(f, QQ.QQ_CHARSET_DEFAULT));
return message.getBytes();
} catch (IOException e) {
log.debug("解析出错");
return null;
}
}
*/
/**
* @return Returns the blue.
*/
public int getBlue() {
return fontStyle.getBlue();
}
/**
* @param blue The blue to set.
*/
public void setBlue(int blue) {
fontStyle.setBlue(blue);
}
/**
* @return Returns the bold.
*/
public boolean isBold() {
return fontStyle.isBold();
}
/**
* @param bold The bold to set.
*/
public void setBold(boolean bold) {
fontStyle.setBold(bold);
}
/**
* @return Returns the encoding.
*/
public char getEncoding() {
return fontStyle.getEncodingCode();
}
/**
* @param encoding The encoding to set.
*/
public void setEncoding(char encoding) {
fontStyle.setEncodingCode(encoding);
}
/**
* @return Returns the fontName.
*/
public String getFontName() {
return fontStyle.getFontName();
}
/**
* @param fontName The fontName to set.
*/
public void setFontName(String fontName) {
fontStyle.setFontName(fontName);
}
/**
* @return Returns the green.
*/
public int getGreen() {
return fontStyle.getGreen();
}
/**
* @param green The green to set.
*/
public void setGreen(int green) {
fontStyle.setGreen(green);
}
/**
* @return Returns the italic.
*/
public boolean isItalic() {
return fontStyle.isItalic();
}
/**
* @param italic The italic to set.
*/
public void setItalic(boolean italic) {
fontStyle.setItalic(italic);
}
/**
* @return Returns the red.
*/
public int getRed() {
return fontStyle.getRed();
}
/**
* @param red The red to set.
*/
public void setRed(int red) {
fontStyle.setRed(red);
}
/**
* @return Returns the underline.
*/
public boolean isUnderline() {
return fontStyle.isUnderline();
}
/**
* @param underline The underline to set.
*/
public void setUnderline(boolean underline) {
fontStyle.setUnderline(underline);
}
/**
* @return Returns the fontSize.
*/
public int getFontSize() {
return fontStyle.getFontSize();
}
/**
* @param fontSize The fontSize to set.
*/
public void setFontSize(int fontSize) {
fontStyle.setFontSize(fontSize);
}
/**
* @return Returns the receiver.
*/
public int getReceiver() {
return receiver;
}
/**
* @param receiver The receiver to set.
*/
public void setReceiver(int receiver) {
this.receiver = receiver;
}
/**
* @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 messageType.
*/
public char getMessageType() {
return messageType;
}
/**
* @param messageType The messageType to set.
*/
public void setMessageType(char messageType) {
this.messageType = messageType;
}
/**
* @return Returns the replyType.
*/
public byte getReplyType() {
return replyType;
}
/**
* @param replyType The replyType to set.
*/
public void setReplyType(byte replyType) {
this.replyType = replyType;
}
/**
* @param filePath The filePath to set.
*/
public void setFileName(String filePath) {
this.fileName = filePath;
}
/**
* @param fileSize The fileSize to set.
*/
public void setFileSize(int size) {
this.fileSize = String.valueOf(size) + " 字节";
}
/**
* @param port The port to set.
*/
public void setDirectPort(int port) {
this.directPort = (char)port;
}
/**
* @return Returns the requestSequence.
*/
public char getSessionId() {
return sessionId;
}
/**
* @param requestSequence The requestSequence to set.
*/
public void setSessionId(char requestSequence) {
this.sessionId = requestSequence;
}
/**
* @return Returns the localIp.
*/
public byte[] getLocalIp() {
return localIp;
}
/**
* @param localIp The localIp to set.
*/
public void setLocalIp(byte[] localIp) {
this.localIp = localIp;
}
/**
* @return Returns the localPort.
*/
public char getLocalPort() {
return localPort;
}
/**
* @param localPort The localPort to set.
*/
public void setLocalPort(int localPort) {
this.localPort = (char)localPort;
}
public byte getTransferType() {
return transferType;
}
public void setTransferType(byte transferType) {
this.transferType = transferType;
}
public boolean isFakeIp() {
return fakeIp;
}
public void setFakeIp(boolean fakeIp) {
this.fakeIp = fakeIp;
}
/**
* @return Returns the fragmentSequence.
*/
public int getFragmentSequence() {
return fragmentSequence;
}
/**
* @param fragmentSequence The fragmentSequence to set.
*/
public void setFragmentSequence(int fragmentSequence) {
this.fragmentSequence = fragmentSequence;
}
/**
* @return Returns the totalFragments.
*/
public int getTotalFragments() {
return totalFragments;
}
/**
* @param totalFragments The totalFragments to set.
*/
public void setTotalFragments(int totalFragments) {
this.totalFragments = totalFragments;
}
/**
* @return Returns the messageId.
*/
public char getMessageId() {
return messageId;
}
/**
* @param messageId The messageId to set.
*/
public void setMessageId(char messageId) {
this.messageId = messageId;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -