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

📄 sendimpacket.java

📁 lumaQQ的源文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	private void initSendFileContent(ByteBuffer buf) {
	    // 17 - 19. 怀疑也和发送消息包相同,但是在这种情况中,这部分没有使用,为全0,一共11个0字节
	    buf.putLong(0);
	    buf.putChar((char)0);
	    buf.put((byte)0);
	    // 我们先尝试UDP方式
	    buf.put(transferType);
	    buf.put((byte)0x0);
	    if(fakeIp) {
	        buf.putInt(0);
	        buf.putChar((char)0);
	    } else {
		    // 四个字节的发送者IP,这是外部IP
		    buf.put(user.getIp());
		    // 发送者端口
		    buf.putChar((char)user.getPort());	        
	    }
	    // 直接端口
	    buf.putChar(directPort);
	    buf.putInt(0);
	    buf.putChar((char)0);
	    buf.put((byte)0x20);
	    buf.put(DELIMIT);
	    buf.put(fileName.getBytes());
	    buf.put(DELIMIT);
	    buf.put(fileSize.getBytes());
	}

	/**
	 * 初始化普通消息包的其余部分
	 * @param buf
	 */
	private void initTextContent(ByteBuffer buf) {
	    // 消息方式,是发送的,还是自动回复的,1字节
	    buf.put(replyType);
	    // 写入消息正文字节数组
	    if(message != null)
	    	buf.put(message);
	    // 最后一个分片时追加空格
	    if(fragmentSequence == totalFragments - 1)
	    	buf.put((byte)0x20);
	    // 消息尾部,字体修饰属性
	    fontStyle.writeBean(buf);
	}

    /**
     * @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 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;
    }

	/**
	 * @return the message
	 */
	public byte[] getMessage() {
		return message;
	}

	/**
	 * @param message the message to set
	 */
	public void setMessage(byte[] message) {
		this.message = message;
	}
}

⌨️ 快捷键说明

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