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

📄 streaminitiationlistener.java

📁 网站即时通讯系统
💻 JAVA
字号:
package com.valhalla.jbother.jabber.smack;import org.jivesoftware.smack.PacketListener;import org.jivesoftware.smack.filter.PacketFilter;import org.jivesoftware.smack.filter.PacketTypeFilter;import org.jivesoftware.smack.packet.IQ;import org.jivesoftware.smack.packet.Packet;import org.jivesoftware.smack.packet.XMPPError;import com.valhalla.gui.*;import com.valhalla.jbother.*;/** * Created by IntelliJ IDEA. * User: luke * Date: Jan 18, 2005 * Time: 10:27:42 AM *//** * incoming StreamInitiation packets are processed by this class. the main task * is to reply to it offering byteatream to the caller */public class StreamInitiationListener implements PacketListener {    private static String fId = "$Id$";    public static final String BYTESTREAMS = "http://jabber.org/protocol/bytestreams";    public StreamInitiationListener() {    }    public void processPacket(Packet packet) {        // <si type="set">        if (packet instanceof StreamInitiation                && ((IQ) packet).getType() == IQ.Type.SET) {            StreamInitiation si = (StreamInitiation) packet;            if (si.getFeature().providesBytestreamOption()) {                // inform the user that someone wants to send him/her a file                // popup "accept file" window. It will take the action from here                FileReceiveDialog frd = new FileReceiveDialog(si);                PacketFilter filter = new PacketTypeFilter(Streamhost.class);                BuddyList.getInstance().getConnection().addPacketListener(frd,                        filter);                frd.setVisible(true);            } else // seems that Initiator is using some other method for                   // sending files than byte streams...            {                IQ errorPacket = new IQ() {                    public String getChildElementXML() {                        return null;                    }                };                errorPacket.setTo(si.getFrom());                errorPacket.setFrom(si.getTo());                errorPacket.setType(IQ.Type.ERROR);                errorPacket.setPacketID(packet.getPacketID());                //          errorPacket.setError(new XMPPError(400,"<bad-request                // xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>\n"                //            + "<bad-profile xmlns=\"http://jabber.org/protocol/si\">"));                errorPacket.setError(new XMPPError(400, "bad-request"));                // send the response                if (BuddyList.getInstance().checkConnection()) {                    BuddyList.getInstance().getConnection().sendPacket(                            errorPacket);                }                return;            }        }    }}

⌨️ 快捷键说明

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