亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
91精品国产美女浴室洗澡无遮挡| 白白色 亚洲乱淫| 91麻豆精品国产| 天堂蜜桃一区二区三区| 在线精品视频免费观看| 亚洲综合激情网| 在线播放91灌醉迷j高跟美女| 日韩精品三区四区| 精品国产a毛片| 国产成人精品1024| 亚洲免费av在线| 欧美日韩国产三级| 激情六月婷婷久久| 久久久精品综合| 不卡影院免费观看| 亚洲小说欧美激情另类| 欧美一区二区福利视频| 国产一区欧美日韩| 1000部国产精品成人观看| 在线免费观看成人短视频| 日韩精品一区第一页| 久久久久9999亚洲精品| 91女厕偷拍女厕偷拍高清| 亚洲成a人v欧美综合天堂下载| 精品少妇一区二区三区免费观看| 风间由美一区二区av101| 亚洲精品国产精华液| 日韩视频在线你懂得| 成人综合激情网| 视频一区中文字幕| 国产精品免费久久| 欧美日韩精品一区二区在线播放 | 成人欧美一区二区三区小说| 欧美日韩在线精品一区二区三区激情 | 国产精品国产精品国产专区不蜜 | 欧美最新大片在线看| 蜜桃视频第一区免费观看| 久久精品视频免费观看| 色播五月激情综合网| 黑人巨大精品欧美一区| 亚洲激情六月丁香| 国产性色一区二区| 在线成人av影院| av欧美精品.com| 黄页网站大全一区二区| 一区二区三区日韩欧美精品| 国产偷v国产偷v亚洲高清| 欧美四级电影在线观看| 高清不卡一区二区| 九九国产精品视频| 亚洲综合成人在线视频| 国产精品免费看片| 久久先锋影音av鲁色资源网| 欧美日韩在线播放一区| 91香蕉视频mp4| 大桥未久av一区二区三区中文| 久久精品国产**网站演员| 亚洲狠狠爱一区二区三区| 中文字幕在线免费不卡| 国产视频在线观看一区二区三区| 日韩一区二区中文字幕| 欧美日韩精品一区二区三区蜜桃 | 裸体健美xxxx欧美裸体表演| 国产精品素人一区二区| 精品精品国产高清a毛片牛牛| 欧美视频精品在线观看| 91蜜桃婷婷狠狠久久综合9色| 国产精品一区二区你懂的| 捆绑变态av一区二区三区| 亚洲国产sm捆绑调教视频 | 久久综合久久鬼色| 欧美一区二区精品| 91精品国产综合久久精品图片| 91搞黄在线观看| 在线欧美日韩精品| 欧美性三三影院| 在线日韩国产精品| 欧美影院一区二区三区| 91视频www| 欧美亚洲动漫精品| 欧美亚洲国产一区在线观看网站| 91网站视频在线观看| 91女厕偷拍女厕偷拍高清| 91免费视频观看| 色乱码一区二区三区88| 日本韩国欧美一区二区三区| 一本色道久久综合精品竹菊| av动漫一区二区| 色天使久久综合网天天| 在线精品视频一区二区三四| 欧美日韩国产影片| 91精品国产丝袜白色高跟鞋| 欧美一卡二卡在线观看| 欧美videossexotv100| 26uuu国产一区二区三区| 国产午夜精品久久久久久免费视 | 国产成人午夜视频| www.色综合.com| 欧美亚洲一区三区| 欧美一区二区三区视频免费| 欧美mv和日韩mv国产网站| 国产欧美一区二区三区沐欲| 自拍偷自拍亚洲精品播放| 亚洲一区二区视频在线观看| 麻豆成人久久精品二区三区红| 国产成人综合视频| 色综合久久中文综合久久牛| 制服丝袜在线91| 久久精品欧美一区二区三区麻豆| 亚洲欧美日韩在线播放| 蜜臀av一区二区在线免费观看 | 裸体歌舞表演一区二区| 国产91丝袜在线18| 欧美在线观看视频在线| 精品成人一区二区| 亚洲天堂福利av| 蜜臀av一区二区三区| 成人国产亚洲欧美成人综合网| 日本丰满少妇一区二区三区| 日韩视频一区二区三区| 欧美国产日本韩| 日本亚洲欧美天堂免费| 成人午夜精品一区二区三区| 欧美日韩情趣电影| 久久久99免费| 婷婷夜色潮精品综合在线| 国产精品亚洲人在线观看| 色域天天综合网| 久久久久成人黄色影片| 午夜视频一区在线观看| 不卡av免费在线观看| 欧美一区二区在线看| 国产精品国产三级国产| 久久精品理论片| 欧美色倩网站大全免费| 国产无遮挡一区二区三区毛片日本| 亚洲大片精品永久免费| 欧美一区二区三级| 国产精品色哟哟网站| 七七婷婷婷婷精品国产| 91麻豆国产福利在线观看| 久久综合色一综合色88| 日韩在线a电影| 欧美亚洲国产怡红院影院| 亚洲国产精品99久久久久久久久| 日韩不卡一区二区三区| 一本大道久久a久久精品综合| 久久久久久久免费视频了| 无码av免费一区二区三区试看 | 成人福利在线看| 精品88久久久久88久久久| 五月综合激情网| 欧美午夜在线一二页| 综合久久久久久| 成熟亚洲日本毛茸茸凸凹| 久久综合久久综合九色| 麻豆精品一二三| 欧美日韩不卡一区二区| 亚洲国产欧美在线人成| 日本韩国欧美国产| 亚洲美女在线一区| 成人av网站免费观看| 国产精品婷婷午夜在线观看| 国产电影一区二区三区| 久久一夜天堂av一区二区三区 | 亚洲一区二区三区在线看 | 欧美日韩国产一级二级| 亚洲一区二区三区激情| 欧洲精品中文字幕| 亚洲一区二区三区四区五区中文| 91影院在线免费观看| 国产精品久久久久久久久免费丝袜 | 国产精品丝袜91| 成a人片国产精品| 国产精品国产a级| av高清不卡在线| 亚洲精品日韩一| 欧美午夜精品久久久久久孕妇| 亚洲精品乱码久久久久久久久| 在线观看不卡视频| 亚洲韩国精品一区| 91精品国产aⅴ一区二区| 日韩av中文字幕一区二区| 日韩一二三四区| 麻豆久久一区二区| 久久噜噜亚洲综合| 成a人片亚洲日本久久| 亚洲精品水蜜桃| 911国产精品| 久久精品国产亚洲一区二区三区| 精品sm捆绑视频| 成人久久18免费网站麻豆| 亚洲欧美成人一区二区三区| 欧美亚洲国产一区二区三区va | 日本韩国精品一区二区在线观看| 亚洲国产综合色| 26uuu精品一区二区在线观看| 成人午夜电影网站| 一区二区三区在线视频免费观看| 在线91免费看|