📄 iport.java
字号:
/*
* LumaQQ - Java QQ Client
*
* Copyright (C) 2004 notXX
* 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;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SelectableChannel;
import edu.tsinghua.lumaqq.qq.events.PacketEvent;
import edu.tsinghua.lumaqq.qq.events.PacketListener;
import edu.tsinghua.lumaqq.qq.events.QQEvent;
import edu.tsinghua.lumaqq.qq.events.QQListener;
import edu.tsinghua.lumaqq.qq.packets.InPacket;
import edu.tsinghua.lumaqq.qq.packets.OutPacket;
/**
* 发送接收包的接口.
*
* @author notxx
* @author 马若劼
*/
public interface IPort {
/**
* 向发送队列添加一个包
*
* @param packet
* 添加的包
*/
public void add(OutPacket packet);
/**
* 清空发送队列和接收队列
*/
public void clear();
/**
* 获得对应的通道
*
* @return 对应的通道
*/
public SelectableChannel channel();
/**
* 关闭这个端口
*
* @throws IOException
* 关闭出错
*/
public void dispose() throws IOException;
/**
* 获得接收队列中的第一个包
*
* @return 第一个包
*/
public InPacket get();
/**
* 把in对象的OutPacket从重发队列中清楚
* @param in
*/
public void removeResend(InPacket in);
/**
* 把一个InPacket推回接收队列,用在登录之前收到包的情况下
* @param in
*/
public void pushBack(InPacket in);
/**
* 发送队列是否是空的
*
* @return 是空的返回true, 否则返回false
*/
public boolean isEmpty();
/**
* 接收一个包到接收队列
*
* @return 如果还有数据可以接收返回true, 否则返回false.
* @throws IOException
* 一般IO错误.
* @throws PacketParseException
* 包格式错误.
*/
public void receive() throws IOException, PacketParseException;
/**
* 移除接收队列中的第一个包.
*
* @return 移除的包.
*/
public InPacket remove();
/**
* 从发送队列发送一个包.
*
* @return 如果还有包需要发送返回true, 否则返回false.
* @throws IOException
* 一般IO错误.
*/
public void send() throws IOException;
/**
* 立即发送一个包,不添加到发送队列
* @param packet
*/
public void send(OutPacket packet);
/**
* 立即发送ByteBuffer中的内容,不添加到发送队列
* @param buffer
*/
public void send(ByteBuffer buffer);
/**
* 添加一个包事件监听器
* @param listener 包事件监听器
*/
public void addPacketListener(PacketListener listener);
/**
* 除去一个包事件监听器
* @param listener 包事件监听器
*/
public void removePacketListener(PacketListener listener);
/**
* 触发包到达事件
* @param e PacketEvent对象
*/
public void firePacketArrivedEvent(PacketEvent e);
/**
* 触发包发送事件
* @param e
*/
public void firePacketSentEvent(PacketEvent e) ;
/**
* 启动端口
*/
public void start();
/**
* @return true表示已经连接上
*/
public boolean isConnected();
/**
* 添加QQ事件监听器
* @param listener QQListener
*/
public void addQQListener(QQListener listener);
/**
* 除去QQ事件监听器
* @param listener QQListener
*/
public void removeQQListener(QQListener listener);
/**
* 清除所有QQ事件监听器
*/
public void removeAllQQListener();
/**
* 触发QQ事件
* @param e QQEvent
*/
public void fireQQEvent(QQEvent e);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -