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

📄 manytomanydialog.java

📁 Myjxta的源代码 基于JXTA的P2P即时通信系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        if (this.myGroupListener != null) {            getGroup().removeListener(myGroupListener);        }        // retrieve the correct instance of the DialogManager        DialogManager dm = DialogManager.getInstance(getGroup(), getGroup().getPeerGroup().getPeerName(), PipeService.PropagateType);        dm.removePipeListener(getGroup().getPeerGroup(), this);        // close the pipe        if (this.pipe != null) {            pipe.close();            setPipe(null, null);        }        this.dialogPanel = null;        super.close();    }    public PluginView getDialogPanel(View p_myJXTAView) {        this.dialogPanel = new ChatDialogView(p_myJXTAView, this);        return dialogPanel;    }    /**     * Dispatch a Message object to the intended receivers.     * This imeplementation send the message down the pipe.     *     * @param msg the Message object to send across an open pipe     * @return <code>true</code> if no Exceptions are encountered while sending     *         the data over the pipe, <code>false</code> otherwise.     */    public boolean dispatch(Message msg) {        boolean isDispatched = false;        if (ACTIVATE_SEQNR) {            if (msg.getMessageElement(SEQ_NR_MSGKEY) == null) {                msg.addMessageElement(new StringMessageElement(SEQ_NR_MSGKEY, Integer.toString(m_lastMessageDispatchNumber), null));            }        }        try {            this.pipe.send(msg);            isDispatched = true;        } catch (IOException ioe) {            LOG.log(Level.SEVERE, "Caught unexpected Exception", ioe);        }        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("End   dispatch(Message)");        }        return isDispatched;    }    /**     * Perform any task  that need to be performed after the     * Message object was send. This implementation does nothing     *     * @param msg the Message object that was send     */    protected void postDispatch(Message msg) {        // Currently, nothing is done after dispatch.        m_lastMessageDispatchNumber++;    }    /**     * Perform any tasks that need to be performed before all     * registered DialogListeners are informed that a new DialogMessage     * object was received. This implementation does not make any     * changes in the DialogMessage object     *     * @param dm the DialogMessage object that was received     * @return the changed DialogMessage image is any     */    protected DialogMessage preReceive(DialogMessage dm) {        return dm;    }    /**     * Sets up all the inbound and outbound filters used by     * this Dialog.     */    private void init() {        // xxx: consider varying filters per dialog in time (eg prefs)        BanFilter banFilter = new BanFilter();        banFilter.setValid(true);        addInboundFilter(banFilter);        URIFilter uriFilter = new URIFilter();        uriFilter.setValid(true);        addInboundFilter(uriFilter);        LegacyAnnounceFilter legacyAnnounceFilter = new LegacyAnnounceFilter();        legacyAnnounceFilter.setValid(false);        addInboundFilter(legacyAnnounceFilter);        PingPresenceFilter pingFilter = new PingPresenceFilter();        pingFilter.setValid(false);        addInboundFilter(pingFilter);        EmoticonFilter emoticonFilter = new EmoticonFilter();        emoticonFilter.setValid(true);        addInboundFilter(emoticonFilter);        HTMLNormalizerFilter htmlNormalizerFilter = new HTMLNormalizerFilter();        htmlNormalizerFilter.setValid(true);        addInboundFilter(htmlNormalizerFilter);        // xxx: encode has "issues"        //this.outbound.addFilter(new EncodeFilter());        EmptyMessageOrCommandFilter emptyMessageOrCommandFilter = new EmptyMessageOrCommandFilter();        emptyMessageOrCommandFilter.setValid(true);        addInboundFilter(emptyMessageOrCommandFilter);        EmptyMessageFilter emptyMessageFilter = new EmptyMessageFilter();        emptyMessageFilter.setValid(true);        addOutboundFilter(emptyMessageFilter);        DirectiveFilter directiveFilter = new DirectiveFilter(getGroup());        directiveFilter.setValid(true);        addOutboundFilter(directiveFilter);        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("banFilter.isValid()                   = " +                    banFilter.isValid());            LOG.fine("directiveFilter.isValid()             = " +                    directiveFilter.isValid());            LOG.fine("emoticonFilter.isValid()              = " +                    emoticonFilter.isValid());            LOG.fine("emptyMessageFilter.isValid()          = " +                    emptyMessageFilter.isValid());            LOG.fine("emptyMessageOrCommandFilter.isValid() = " +                    emptyMessageOrCommandFilter.isValid());            LOG.fine("htmlNormalizerFilter.isValid()        = " +                    htmlNormalizerFilter.isValid());            LOG.fine("legacyAnnounceFilter.isValid()        = " +                    legacyAnnounceFilter.isValid());            LOG.fine("pingFilter.isValid()                  = " +                    pingFilter.isValid());            LOG.fine("uriFilter.isValid()                   = " +                    uriFilter.isValid());            LOG.fine("End   init()");        }    }    /**     * Checks whether the desired OutputPipe was already     * created and is currently in our cache     *     * @param pa the PipeAdvertisement of the desired pipe     * @return an OutputPipe object if it existed in our cache, null     *         otherwise     */    private OutputPipe getPipe(PipeAdvertisement pa) {        return (this.pipeCache != null &&                this.pipeCache.containsKey(pa) ?                this.pipeCache.get(pa) : null);    }    /**     * Updates the {@link #pipe pipe} member variable and     * adds the pipe to the cache if it was not already added     *     * @param pa   the PipeAdvertisement describing the pipe     * @param pipe the OutputPipe to use to send  messages     */    private void setPipe(PipeAdvertisement pa, OutputPipe pipe) {        // set the pipe member variable        this.pipe = pipe;        // put the pipe in the cache if need be        if (pa != null) {            if (this.pipeCache == null) {                this.pipeCache = new HashMap<PipeAdvertisement, OutputPipe>();            }            if (!this.pipeCache.containsKey(pa)) {                this.pipeCache.put(pa, this.pipe);            }        }        // change the connection status of this Dialog    }    public boolean isConnected() {        //if we arent connected to the group (to the rdv of the group) propagation pipes        //are not working --> not connected until we are connected to the group        return this.pipe != null && !this.pipe.isClosed() && this.getGroup().isConnected();    }    // DialogPipeListener methods    /**     * Called if a new Message object was received     *     * @param pg  the PeerGroup in which this message was send     * @param msg the newly received message     */    public void receive(PeerGroup pg, Message msg) {        // xxx: what of pg        receive(msg);    }    /**     * Called if a new JxtaBiDiPipe was opened for the indicated     * PeerGroup. This implementation does nothing     *     * @param pg   the PeerGroup in which this  pipe was opened     * @param pipe the JxtaBiDiPipe on which messages are send     */    public void receive(PeerGroup pg, JxtaBiDiPipe pipe) {        // Currently, BiDi Pipes are ignored.    }}

⌨️ 快捷键说明

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