现在的位置: 首页 > 综合 > 正文

Peerdroid教程(翻译)

2013年09月11日 ⁄ 综合 ⁄ 共 7562字 ⁄ 字号 评论关闭

Peerdroid教程(翻译)

 

出自:http://code.google.com/p/peerdroid/wiki/PeerDroidTutorial

 

PeerDroidTutorial to understand the architecture and run the rendezvous(RDV) and sampleapplications

peerdroid教程用于了解peerdroid的体系结构,和运行汇聚点(RDV及示例应用程序

介绍

PeerDroid isthe porting of JXME protocol to Android Platform. It allows the AndroidDevelopers to create application for Android platform that uses the features ofJXTA system along with
Android potential, interacting with other mobileterminals and other traditional peers (Personal-Computer).

peerdroid移植Android平台JXME协议它允许开发者Android平台上创建应用程序发挥JXTA系统的特点以及Android潜力与其他移动终端和其他传统节点(个人电脑)互动。

For someinformation about JXTA you can see to official programmers guide at:https://jxta-guide.dev.java.net/.

了解一些信息关于JXTA,你可以看官方程序指南https://java.net
/project/jxta

JXTAProgrammars Guide describes the following kind of peers:

JXTA程序指南描述了以下类型的节点:

•Minimal-Edgepeers: Peers that implement only the required core JXTA services and may relyon other peers to act as their proxy for other services to fully participate ina JXTA Network.
The proxy peers act as proxy for the non-core services. Typicalminimal-edge peers include sensor devices and home automation devices,

最小边缘节点:该节点实现所需的核心jxta服务,和可能依赖于其他节点的其他服务作为他们代理来充分参与JXTA网络代理节点作为非核心服务代理典型的最小边缘节点包括:传感器装置和家庭自动化设备

•Full-EdgePeer: Peers that implements all of the core and standard JXTA services and canparticipate in all of the JXTA protocols. These peers form the majority ofpeers on a JXTA network
and can include phones, PC's, servers, etc.

节点:该节点实现所有的核心和JXTA服务标准能参与所有JXTA协议这些节点大部分来自JXTA网络,包括:手机个人电脑服务器等。

•Super-Peer:Peers that implement and provision resources to support the deployment andoperation of a JXTA network. There are three key JXTA Super Peer functions. Asingle peer may implement
one or more of these functions.

超级节点该节点实现和提供资源支持,部署和操作一个JXTA网络。有三个关键的JXTA超级节点功能一个单独节点可以实现一个或多个这些功能

•Relay: Usedto store and forward messages between peers that do not have directconnectivity because of firewalls or NAT. Only peers which are unable toreceive connections from other peers
require a relay.

中继器用来在节点间存储和转发信息,不能直接连接,由于防火墙或NAT,只有节点无法接收连接时,从其他节点需要一个中继器。

•Rendezvous:Maintains global advertisement indexes and assists edge and proxied peers withadvertisement searches. Also handles message broadcasting.

汇聚点:保持全球广告指标,帮助边缘点和代理节点广告搜索也可以处理消息广播

•Proxy: Usedby minimal-edge peers to get access to all the JXTA network functionalities.The proxy peer translates and summarizes requests, responds to queries andprovides support functionality
for minimal-edge peers.

代理:用于最小的边缘节点获得所有JXTA网络功能。代理节点传递和概述了请求响应查询并提供最小的边缘节点支持功能

 

Thistutorial shows how you can run a RDV and different nodes based on our portingwith some traditional JXTA peers.

本教程演示你将怎么运行一个RDV不同节点。基于我们的移植和一些传统的JXTA节点

AvailableApplications and Software are:

可用的应用程序和软件有:

1•peerdroid.jar

peerdroid.jar

2•PeerDroidSample Application with:

peerdroid示例应用程序,如下:

◦Serviceclasses to manage in a easy way JXTA Connection,Socket, and peerList

服务类用一个简单的方法来管理JXTA连接SocketADVpeerlist

◦Simple GUIto show incoming messages, network's status and available peer list

简单的GUI显示收到的信息网络状态和可用的对等点列表

3•JXTASample Application that you can run on traditional PCs with the samecharacteristics of the previous one but without the GUI.

JXTA示例应用程序,您可以在传统的个人电脑运行,比较与之前相同的特征,但没有GUI

•A simple RDVthat EDGE nodes can use to join a JXTA Network

一个简单的RDV边缘节点可以用于加入一个JXTA网络

Thistutorial as our project is in a early phase and it is in developing followingour last updates. We are waiting your feedbacks to fix bugs and improvefeatures and characteristics of PeerDroid.

本教程对于我们的项目处在早期阶段,它的发展我们最后的更新下。我们正在等待您的反馈来修复的错误和完善peerdroid的功能和特点

 

 

 

RDV

"Maintainsglobal advertisement indexes and assists edge and proxied peers withadvertisement searches. Also handles message broadcasting." (From JXTAGuide)

维持全球广告索引,帮助边缘点和代理节点广告搜索也可以处理消息广播(出自JXTA指南)

You can downloadRDV's codes from the Download Section or with the SVN Repository and import itwith Eclipse or start it with the provided Ant script. The RDV must be executedon a computer
inside the LAN where you are testing the P2P application or ifyou want you can run it on a machine with a public IP in order to be reachedfrom everyone.

你可以下载RDV代码,从下载部分或者从SVN资源库,和用Eclipse导入它或启用它,或用提供的Ant脚本启动它RDV必须执行在一个计算机局域网里面,当你正在测试的P2P应用,或者如果你想你能运行它在一个公共IP设备,让每个人都能到达。

Peers thatcome into the network need to know the RDV's IP in order to contact him andJoin into the JXTA system. For this reason you must provide a simple txt file(called in our examples
rdvlist.txt ) that contains information about one ormore rendezvous.

该节点进入网络需要知道RDVIP,为了联系他而加入这个JXTA系统为此,您必须提供一个简单的
txt 文件(在我们的例子里称rdvlist.txt包含关于一个或多个汇聚点的信息

This is anexample of "rdvlist.txt" where we are adding information about Ip andavailable ports:

这是一个rdvlist.txt例子。我们在那里添加信息,关于IP有效的端口

tcp://160.78.28.131:9701

TCP /160.78.28.131:9701

http://160.78.28.131:9700

http//160.78.28.131:9700

Link to thisfile will be used in PeerDroid application and also in traditional JXTAsolution to reach our RDV. (This is a tradition approach for JXTA solutions)

使用peerdroid应用链接到这个文件,也是到达我们的RDV传统JXTA方案。这是一个传统的决方法,对于JXTA方案)

 

 

 

peerdroid示例应用程序

PeerDroidSample Application is based on the porting of JXME for the Android's platformand provides a simple application to show the basic features. He has some Classthat try to simplify
the configuration of a JXTA's node and the comunicationscalled JXTAService and SocketService. In the next release of peerdroid, methodsof these classes will be improved to provide a complete set of functionalityfor delevopers.

peerdroid示例应用程序是基于移植JXMEAndroid平台,提供了一个简单的应用程序来显示它的基本特征他有一些类,尽量简化JXTA节点的配置和通讯,称为jxtaservicesocketservicepeerdroid一个发布里,这些类的方法改进,并为开发者们提供一套完整的功能

PeerDroidSamplecan be retrieved from Download section or from SVN and can be imported usingEclipse and hid Android plugin. Open peerdroid.sample.service.JXTAService andchange the variable
called rdvlist with the address of you RDV List definedabove.

peerdroidsample可以从下载部分或SVN恢复,能使用Eclipse导入和隐藏Android插件开放peerdroid.sample.service.jxtaservice更改叫rdvList的地址变量,在你RDV列表上定义。

privatestatic String rdvlist = "http://www.example.com/rdvlist.txt";

privatestatic String rdvlist = "http://www.example.com/rdvlist.txt";

The first method called after the initialization ofvariables is "start()". In this method there are all configuration ofJXTA peer like:

变量初始化后,第一种方法称为start()在该方法中JXTA节点所有的配置

NB: For theother configuration information you can see the JXTA Guide.

注:对于其他的配置信息,你可以看JXTA指南

 

节点配置

config.setPeerID(IDFactory.newPeerID(PeerGroupID.defaultNetPeerGroupID));

config.setName(instanceName);

config.setDescription("Createdby AndroidTester");

config.setMode(NetworkConfigurator.EDGE_NODE);

config.setPrincipal(principal);

config.setPassword(password);

config.setUseMulticast(false);

网络配置

netPeerGroup= networkManager.startNetwork();

rendezvous= netPeerGroup.getRendezVousService();

discovery= netPeerGroup.getDiscoveryService();

Socket Service配置

创建服务一个我们的服务类)允许管理基于JXTASocket的传入和传出连接.

socketService= new SocketService(this);

发布Pipe广告

 从SocketService.开始启动

discovery.publish(socketService.getPipeAdv());

discovery.remotePublish(socketService.getPipeAdv());

等待 RDV 连接

while(!rendezvous.isConnectedToRendezVous()) {

        Log.d(PeerDroidSample.TAG, "Waitingfor rendezvous connection!!!");

        synchronized (rendezvous) {

               try {

                       rendezvous.wait(1000);

               } catch (InterruptedException e){

                       e.printStackTrace();

               }

        }

}

 

 

 

JXTA peerdroidsample

This is asample application that you can use to create an heterogeneous network.JXTA-PeerDroidSample is based on standard JXTA library, but we are working tocreate the same level abstraction
of PeerDroid in order to create in a easy waythe JXTA features. For this reason you can find our service classes likeJXTAService and SocketService.

这是一个示例应用程序,可以使用它来创建一个异构网络JXTA
peerdroidsample
基于标准的JXTA但我们正在创建与之相同级别的抽象peerdroid。为JXTA特征创建一个容易的方法。出于这个原因,你可以找到我们的服务,像jxtaservicesocketservice

To start theapplication you must change the rdv list as we have done in the previousapplication. You have to go inside peerdroid.sample.service.JXTAService andchange:

启动应用程序,您必须更改rdvlist我们已经在前面的应用有示例了。你要进去peerdroid.sample.service.jxtaservice去更改:

privatestatic String rdvlist = "http://www.example.com/rdvlist.txt";

with the list of your rdv.

改成你的RDV

 

抱歉!评论已关闭.