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

📄 vojxtacommand.java

📁 Myjxta的源代码 基于JXTA的P2P即时通信系统
💻 JAVA
字号:
/* * Created on Feb 25, 2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */package net.jxta.myjxta.plugins.vojxta.command;import net.jxta.document.MimeMediaType;import net.jxta.document.StructuredDocument;import net.jxta.document.StructuredTextDocument;import net.jxta.endpoint.TextDocumentMessageElement;import net.jxta.myjxta.dialog.Dialog;import net.jxta.myjxta.dialog.DialogMessage;import net.jxta.myjxta.util.Group;import net.jxta.peergroup.PeerGroup;import net.jxta.pipe.PipeService;import net.jxta.protocol.PipeAdvertisement;import net.jxta.myjxta.plugins.vojxta.VoJxtaDialog;import net.jxta.myjxta.dialog.DialogManager;import net.jxta.myjxta.dialog.commands.AbstractCommand;import java.util.logging.Level;import net.jxta.logging.Logging;import java.util.logging.Logger;/** * @author Ravi * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */public class VOJXTACommand extends AbstractCommand {    public static final String ID = VOJXTACommand.class.getName();           public static final String PIPE = "vojxtapipe";    private static final Logger LOG = Logger.getLogger(VOJXTACommand.class.getName());        public String getId () {        return ID;    }        public boolean process (Dialog dialog, DialogMessage msg) {        LOG.setLevel(Level.INFO);        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("process: " + (msg != null ? msg.toString()                                                : null));        }                String cmd = msg != null ? msg.getCommand () : null;        Group g = dialog.getGroup ();        PeerGroup pg = g.getPeerGroup ();        DialogMessage dm = new DialogMessage (pg.getPeerName (), null,                pg.getPeerGroupID ().toString (), pg.getPeerGroupName ());                if (cmd != null &&                cmd.length () > 0) {                        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                LOG.info("processing command: " + cmd);            }                        setCommand (cmd);                        //get pipe adv from DialogManager            StructuredDocument d = getPipeAdv (g);            //attach it as a message element            TextDocumentMessageElement te = d != null ?                new TextDocumentMessageElement (PIPE,                    (StructuredTextDocument)d, null) :                null;                        if (te != null) {                setReply ("pipe:" + PIPE);                setStatus (true);                                dm.setCommand (getResponse ());                dm.addMessageElement (PIPE, te);                                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("results: " + dm);                }            } else {                if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                    LOG.severe("can\'t construct document");                }            }                    } else {            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.severe("invalid command: " + cmd);            }        }                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("dispatching: " + (dm != null ? dm.toString()                                                   : null));        }                dialog.dispatch (dm);                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("dispatching: " + getStatus());        }        //LOG.setLevel(Level.SEVERE);        return getStatus ();    }        private StructuredDocument getPipeAdv (Group g) {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("getPipeAdvl");        }                String pn = Dialog.getDialogNamer (VoJxtaDialog.class).                getDialogName (g.getPeerGroup ().getPeerName ());        PipeAdvertisement pa = DialogManager.getInstance (g, pn,                PipeService.UnicastType).getPipeAdv (g.getPeerGroup ());                return (StructuredDocument)pa.getDocument (MimeMediaType.XMLUTF8);    }}

⌨️ 快捷键说明

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