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

📄 slideshowservice.java

📁 基于jxta的局域网P2P文件共享,可以实现局域网中的文件p2p共享,实现文件快速传输及交流
💻 JAVA
字号:
package connex.plugins.slideshow;

import connex.session.plugin.Plugin;
import javax.swing.JPanel;
import net.jxta.jxtacast.JxtaCastEventListener;
import net.jxta.jxtacast.JxtaCastEvent;
import net.jxta.jxtacast.JxtaCast;
import connex.core.WS.Workspace;
import java.io.File;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2006</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class SlideShowService implements Plugin , JxtaCastEventListener{
  private SlideShowGUI gui;
  private JxtaCast jc;
  private Workspace ws;
  private static SlideShowService instance = null;
  public SlideShowService() {
    instance = this;
  }

  public void initPlugin(Object param) {
    this.ws = (Workspace) param;
    jc = new JxtaCast(ws.getPeerAdv(),ws.getPeerGroup(),"ConneX_SlideShow");

    gui= new SlideShowGUI();


  }

  public void startPlugin() {
    jc.addJxtaCastEventListener(this);
    jc.logEnabled=true;
    jc.start();
  }

  public JPanel getMainUI() {
    return gui;
  }

  public void stopPlugin() {

    jc.removeJxtaCastEventListener(this);

    jc.stop();
  }

  public void pausePlugin() {
  }

  public void createSession(String id) {
  }
  public void sendPicture(File file){
    System.out.println(file.getAbsoluteFile());
    jc.sendFile(file,"ConneXSlide");
  }

  public void jxtaCastProgress(JxtaCastEvent e) {
    gui.updateProgress(e.percentDone);
       if (e.transType == 0) {
           gui.setState("Sending...");


       } else {
           gui.setState("Receiving from " + e.sender);
       }

       if (e.percentDone == 100) {
           long en = System.currentTimeMillis();

           System.err.println(en  + " :MyFile: type" +
                              e.transType + " : caption" + e.caption +
                              e.percentDone);
           if (e.transType != 0) {


              try {
               gui.display( e.filename);
             } catch (Exception ex) {
             }

           }
           gui.setState("Waiting for Picture");
       }

   }
   public static SlideShowService getInstance(){
     if(instance==null){
       instance= new SlideShowService();
     }
     return instance;
   }


}

⌨️ 快捷键说明

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