亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? restopeerservice.java

?? p2p 源代碼
?? JAVA
字號:
import java.io.*;import java.util.*;import java.net.URL;import net.jxta.service.Service;import net.jxta.peergroup.PeerGroup;import net.jxta.peergroup.PeerGroupFactory;import net.jxta.exception.PeerGroupException;import net.jxta.document.AdvertisementFactory;import net.jxta.document.StructuredDocumentFactory;import net.jxta.document.Advertisement;import net.jxta.document.Element;import net.jxta.document.TextElement;import net.jxta.document.MimeMediaType;import net.jxta.document.StructuredDocument;import net.jxta.document.StructuredTextDocument;import net.jxta.discovery.DiscoveryService;import net.jxta.pipe.PipeService;import net.jxta.pipe.InputPipe;import net.jxta.pipe.OutputPipe;import net.jxta.pipe.PipeID;import net.jxta.protocol.PipeAdvertisement;import net.jxta.protocol.PeerGroupAdvertisement;import net.jxta.protocol.ModuleImplAdvertisement;import net.jxta.endpoint.Message;import net.jxta.id.IDFactory;import net.jxta.id.ID;// The class RestoPeerService is an example of a PeerGroup Service.// This service is registered as a RestoNet Peergroup service.// This service implements the RestoPeer service for Chez JXTA.public class RestoPeerService implements Service {    // Service Module Spec Index ID    public static String Module_Spec_ID =        "jxta:uuid-737D1ED776B043E7A8718B102B62055A05";    private String brand = "Chez JXTA";         // Brand of this restaurant    private String specials = "large ($3.00)";  // Current restaurant Special    private PeerGroup restoNet = null;   // The RestoNet Peergroup    private PipeService pipes = null;    // Pipe service in the RestoNet    private ModuleImplAdvertisement srvImpl = null;    private PipeAdvertisement myAdv = null;  // My pipe advertisement    private InputPipe pipeIn = null;         // Input pipe that we listening                                             // to for requests    private int rtimeout = 8000;             // Resolver pipe timeout    // Service objects are not manipulated directly to protect usage    //of the service. A Service interface is returned to access the service    public Service getInterface() {        return this;    }    // Returns the module impl advertisement for this service.    public Advertisement getImplAdvertisement() {        return srvImpl;    }    // Called when the peergroup initializes the service    public void init(PeerGroup group, ID assignedID, Advertisement impl) {        // Save the RestoNet pointer, the pipe and the RestoPeer Service        restoNet = group;        srvImpl = (ModuleImplAdvertisement) impl;        System.out.println("Initialization RestoPeer Special Service: " +                           srvImpl.getModuleSpecID());        // Extract the service pipe advertisement from the service        // module impl Advertisement. The client MUST use the same pipe        // advertisement to talk to the service. When the client        // discovers the peergroup advertisement, it will extract the        // pipe advertisement to create the connecting pipe by getting        // the module impl advertisement associated with the RestoPeer        // service.        System.out.println("Extract the pipe advertisement from the Service");        PipeAdvertisement pipeadv = null;        try {            // Extract the pipe adv from the Module impl param section            myAdv = (PipeAdvertisement)                AdvertisementFactory.newAdvertisement((TextElement)                      srvImpl.getParam().getChildren().nextElement());        } catch (Exception e) {            System.out.println("failed to read/parse pipe advertisement");            e.printStackTrace();            System.exit(-1);        }        // Start the RestoPeer service loop thread to respond to Hungry peers        // fries requests. Start a new thread for processing all the        // requests        HandleFriesRequest peerRequest = new HandleFriesRequest();        peerRequest.start();    }    // Called when the service is started    public int startApp (String args[]) {        // nothing to do here        return 0;    }    // Called just before the service is stopped    public void stopApp() {    }    // Thread to handle fries auction requests from HungryPeers.    // The method waits for HungryPeer requests pipe messages to arrive.    // Incoming requests contain a pipe advertisement to respond to the    // HungryPeers requester and a fries size.    // The method generates a bid offer for the request, opens an output    // pipe to the HungryPeer requester and send the response.    private class HandleFriesRequest extends Thread {        InputStream ip = null;               // Input Stream of message        PipeAdvertisement hungryPipe = null; // HungryPeer Requester pipe        StructuredDocument request = null;   // Request document        StructuredDocument bid = null;       // Bid response        MimeMediaType mimeType = new MimeMediaType("text", "xml");        Element el = null;                   // Element in document        String name = null;                  // Name of the sender        String size = null;                  // Fries size Requested        OutputPipe pipeOut = null;           // Output pipe to respond to                                             // HungryPeer requester        public void run() {            // Need to check that the Pipe peergroup service of            // RestoNet is initialized. Peergroup services are loaded            // dynamically. Here we just wait until the pipe service            // is initialized so we can create a new pipe.            try {                while (pipes == null) {                    Thread.sleep(2000);                    pipes = restoNet.getPipeService();                }                // Create the input pipe to receive incoming request                if (!createRestoPipe()) {                    System.out.println(                        "Aborting due to failure to create RestoPeer pipe");                    return;                }            } catch (Exception ex) {                    System.out.println(                           "Exception while creating RestoPeer pipe");                    return;            }            System.out.println("RestoNet Restaurant (" + brand +                           ") waiting for HungryPeer requests");            // Loop waiting for HungryPeer Requests            while (true) {                Message msg = null;          // incoming pipe message                try {                    // Block until a message arrive on the RestoPeer pipe                    msg = pipeIn.waitForMessage();                    // If message is null, discard message                    if (msg == null) {                        if (Thread.interrupted()) {                            // We have been asked to stop                            System.out.println("Abort: RestoPeer interrupted");                            return;                        }                    }                    // We received a message; extract the request                    try {                        // Extract the HungryPipe pipe information                        // to reply to the sender                        ip = msg.getElement("HungryPeerPipe").getStream();                        // Construct the associated pipe advertisement                        // via the AdvertisementFactory                        hungryPipe = (PipeAdvertisement)                        AdvertisementFactory.newAdvertisement(mimeType, ip);                        // Extract the sender name and fries size requested                        // building a StructuredDocument                        ip = msg.getElement("Request").getStream();                        request = StructuredDocumentFactory.                                    newStructuredDocument(mimeType, ip);                        // Extract the fields from the structured Document                        Enumeration enum = request.getChildren();                        // Loop over all the elements of the document                        while (enum.hasMoreElements()) {                            el = (Element) enum.nextElement();                            String attr = (String) el.getKey();                            String value = (String) el.getValue();                            // Extract the HungryPeer Requester Name                            if (attr.equals("Name")) {                                name = value;                                continue;                            }                            // Extract the Fries  size requested                            if (attr.equals("Fries")) {                                size = value;                                continue;                            }                        }                    } catch (Exception e) {                        // Broken Content                        continue;                    }                    System.out.println("Received Request from HungryPeer "                               + name + " for " + size + " Fries.");                    // The auction request is valid. We can                    // create the output pipe to send the response bid to                    // the HungryPeer requester                    try {                        System.out.println(                           "Attempting to create Output Pipe to HungryPeer " +                            name);                        // Create an output pipe connection to the HungryPeer                        // requester                        pipeOut = pipes.createOutputPipe(hungryPipe, rtimeout);                        // Check if we have a pipe                        if (pipeOut == null) {                            // Cannot conect the pipe                            System.out.println(                                "Could not find HungryPeer pipe");                            continue;                        }                    } catch (Exception e) {                        // Pipe creation exception                        System.out.println(                            "HungryPeer may not be listening anymore");                        continue;                    }                    // We have a pipe connection to the HungryPeer. Now                    // create the bid response document                    try {                        bid = StructuredDocumentFactory.newStructuredDocument(                                     mimeType, "RestoNet:Bid");                        // Set the Bid values (Brand, price, special)                        // in the response document                        el = bid.createElement("Brand", brand);                        bid.appendChild(el);                        el = bid.createElement("Price", ""+ friesPrice(size));                        bid.appendChild(el);                        el = bid.createElement("Specials", specials);                        bid.appendChild(el);                        // Create a new pipe message                        msg = pipes.createMessage();                        // Add the Bid offer to the message                        msg.addElement(msg.newMessageElement(                                   "Bid", mimeType, bid.getStream()));                        pipeOut.send(msg);                        pipeOut.close();                    } catch (Exception ex) {                        System.out.println(                            "Error sending bid offer to HungryPeer " + name);                    }                    System.out.println("Sent Bid Offer to HungryPeer ("                        + name  + ") Fries price = "  + friesPrice(size) +                        ", special = " + specials);                } catch (Exception e) {                    System.out.println("Abort RestoPeer interrupted");                    return;                }            }        }    }    // Determine the price of the French fries depending on the size    private String friesPrice(String size) {        if (size.equals("small"))              return "$1.50";        if (size.equals("medium"))              return "2.50";        if (size.equals("large"))              return "3.00";        return "error";    }    // Create the input endpoint    private boolean createRestoPipe() {        try {            // Create my input pipe to listen for hungry peers            // requests            pipeIn = pipes.createInputPipe(myAdv);        } catch (Exception e) {            System.out.println(                "Could not initialize the Restaurant pipe" + e.getMessage());            return false;        }        return true;    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久久99精品| 精品视频色一区| 免费成人在线观看视频| 亚洲男人的天堂av| 日韩理论片在线| 一区二区在线看| 亚洲福利一区二区| 亚洲va欧美va人人爽午夜| 亚洲高清三级视频| 日本成人超碰在线观看| 久久国产综合精品| 国产精品一区免费视频| av午夜一区麻豆| 在线观看欧美黄色| 欧美区在线观看| 亚洲成人自拍偷拍| 美女一区二区在线观看| 久久66热偷产精品| 丁香婷婷综合网| 欧洲人成人精品| 欧美一区二区精品在线| 国产亚洲欧美色| 亚洲欧美综合在线精品| 午夜亚洲国产au精品一区二区| 视频精品一区二区| 国产成人免费av在线| av爱爱亚洲一区| 欧美精品日韩精品| 国产午夜精品久久| 五月婷婷综合在线| 国产v综合v亚洲欧| 欧美日韩免费观看一区二区三区 | 国产精品自拍网站| 99国产欧美久久久精品| 欧美日本一区二区三区四区 | 国产电影精品久久禁18| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 色欧美片视频在线观看| 欧美一区二区三区啪啪| 国产精品国产自产拍在线| 无码av免费一区二区三区试看 | 欧美日本视频在线| 中文字幕日韩欧美一区二区三区| 午夜激情综合网| 成人久久久精品乱码一区二区三区| 欧美视频一区二区在线观看| 国产欧美日韩中文久久| 日韩精品一二三四| 一本久道久久综合中文字幕| 久久综合国产精品| 五月婷婷另类国产| 色婷婷久久久亚洲一区二区三区 | 亚洲第一激情av| www.亚洲人| 久久久精品免费免费| 日日欢夜夜爽一区| 欧美制服丝袜第一页| 欧美韩国日本不卡| 国内精品视频666| 欧美一级日韩不卡播放免费| 一区av在线播放| 日本电影欧美片| 日韩理论片一区二区| 国产iv一区二区三区| 日韩丝袜情趣美女图片| 亚洲成a人v欧美综合天堂下载| 色婷婷综合久久久| 一区二区三区四区五区视频在线观看| 成人综合在线视频| 久久婷婷综合激情| 国产麻豆一精品一av一免费| 日韩午夜在线播放| 久久99精品久久久久久| 欧美va天堂va视频va在线| 麻豆精品视频在线观看免费| 精品美女被调教视频大全网站| 三级精品在线观看| 欧美一区二区三级| 久久66热re国产| 久久久午夜精品理论片中文字幕| 国产中文一区二区三区| 久久精品这里都是精品| 国产传媒欧美日韩成人| 国产色产综合色产在线视频| 国产成人一级电影| 日本一区二区三区久久久久久久久不| 不卡的看片网站| 亚洲九九爱视频| 制服丝袜在线91| 国产精品一区在线| 最新国产精品久久精品| 欧美日韩在线播放三区| 日本大胆欧美人术艺术动态| www国产成人免费观看视频 深夜成人网| 国产真实精品久久二三区| 亚洲色图一区二区三区| 欧美视频你懂的| 日韩av在线发布| 欧美国产激情一区二区三区蜜月 | 日韩视频一区二区在线观看| 久久99国产精品久久99 | 91精品国产91久久久久久最新毛片| 日本欧美一区二区| 久久看人人爽人人| 在线亚洲一区观看| 激情五月激情综合网| 亚洲区小说区图片区qvod| 欧美卡1卡2卡| 国产91对白在线观看九色| 亚洲自拍偷拍九九九| 久久综合国产精品| 欧美色视频在线观看| 国产传媒日韩欧美成人| 天天射综合影视| 国产精品欧美综合在线| 欧美一区二区在线看| 一本一道波多野结衣一区二区| 蜜桃精品视频在线观看| 亚洲精品视频一区| 久久久噜噜噜久久中文字幕色伊伊 | 亚洲一区精品在线| xvideos.蜜桃一区二区| 欧美亚洲综合一区| 国产精品1024| 五月激情六月综合| 一区二区成人在线观看| 国产精品久线观看视频| 日韩欧美精品三级| 91久久精品午夜一区二区| 国产高清久久久| 蜜臀久久99精品久久久久久9| 一片黄亚洲嫩模| 亚洲品质自拍视频网站| 国产精品视频第一区| 精品国产91亚洲一区二区三区婷婷| 欧美午夜电影网| 97精品国产露脸对白| 国产一区二区看久久| 国内精品伊人久久久久影院对白| 无码av免费一区二区三区试看 | 日韩精品每日更新| 亚洲日本韩国一区| 国产精品毛片久久久久久久| 国产欧美一区二区精品秋霞影院| 日韩女优制服丝袜电影| 欧美一区二区网站| 欧美精品一级二级三级| 777a∨成人精品桃花网| 91精品国产麻豆国产自产在线| 欧亚一区二区三区| 91黄视频在线| 欧洲一区二区三区在线| 日本道色综合久久| 欧美日韩精品一区二区天天拍小说 | 狠狠色伊人亚洲综合成人| 日本成人在线网站| 青青青爽久久午夜综合久久午夜| 亚洲小少妇裸体bbw| 夜夜嗨av一区二区三区四季av | 免费在线视频一区| 日本欧美在线观看| 久久99国产精品尤物| 国产精品综合一区二区三区| 国产伦精品一区二区三区免费迷 | 精品一区二区三区蜜桃| 激情欧美一区二区| 国产精品99久久久| 成人a级免费电影| 91在线视频18| 欧美丰满一区二区免费视频| 欧美一级高清片| 久久精品人人做人人爽97 | 色哟哟国产精品免费观看| 91久久免费观看| 91精品国产高清一区二区三区 | 天天亚洲美女在线视频| 久久 天天综合| 99vv1com这只有精品| 欧美日韩亚洲综合| 久久久蜜桃精品| 夜夜爽夜夜爽精品视频| 久久精品国产亚洲高清剧情介绍 | 国产日韩精品视频一区| 一区二区在线看| 蜜臀91精品一区二区三区| 国产91综合网| 欧美亚洲日本一区| 国产亚洲一区字幕| 一区二区三区日韩精品| 精品亚洲国产成人av制服丝袜| a美女胸又www黄视频久久| 欧美绝品在线观看成人午夜影视| 久久综合九色综合欧美亚洲| 亚洲日本成人在线观看| 国内精品久久久久影院薰衣草| 色狠狠色狠狠综合| 久久精品视频在线免费观看 | 久久久夜色精品亚洲| 亚洲国产一二三| jiyouzz国产精品久久|