当前位置: 首页 > 软件库 > 程序开发 > 网络工具包 >

p

Peer-to-peer networking with browsers
授权协议 View license
开发语言 C/C++
所属分类 程序开发、 网络工具包
软件类型 开源软件
地区 不详
投 递 者 程俊力
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

P is for peer-to-peer networking with browsers

P is a small framework used to create browser-to-browser networks (as opposed to just a connection). With P, you can:

  • Connect to other browsers using a simple WebSocket server.
  • Connect to other browsers using your established connections to other browsers. This is what makes P unique: it allows for transitive connections across peers, allowing easy creation of mesh networks.

After a connection is established the middleman is no longer necessary – no proxies are involved.

This is made possible by an unstable and young technology -- WebRTC.Currently, only Chrome and Firefox support this technology.

onramp, a simple WebSocket server, is used as the signaling channelto establish initial connections.

API

// Initializing
var rootNode = P.create(); // create the root node

// Connection management
var webSocketNode = rootNode.connect(address); // connect to an onramp WebSocket server
var webRtcNode = webSocketNode.connect(address); // connect to a peer using an onramp connection
var webRtcNode = webRtcNode.connect(address); // connect to a peer using an existing peer connection
anyNode.close(); // close the connection
anyNode.isOpen(); // return true if the connection is open
var nodeArray = anyNode.getPeers(); // returns an array of all peer connections

// Firewalling connections
var protectedNode = P.create({
  firewall: function(offerData){
    // Only accept RTC connection offers which send 'secret' as the offer data
    // this firewall rule will apply to any child nodes as well
    return offerData === 'secret';
  }
});


// Send offerData with a connection request
anyNode.connect({address: address, offerData: 'secret'});


// Sending and receiving messages
webRtcNode.send(message); // send a message to a peer; can be json, string, or arraybuffer
webRtcNode.on('message', function(message){}); // listens for messages from a peer
webRtcNode.on('array buffer', function(arrayBuffer){}); // listens for array buffers from a peer

// Events
anyNode.on('connection', function(peerNode){}); // emitted when a connection is made via this peer
anyNode.on('open', function(){}); // emitted when this connection is open and ready
anyNode.on('close', function(){}); // emitted when this connection is closed
anyNode.on('error', function(err){}); // listens for errors for this connection
anyNode.removeListener(eventName, optionalCallback); // stops listening to an event

Documentation

Release Notes

  • 0.3.3 - Fixed an issue in FF which caused disconnections shorting after successful connections due to a GC miscommunication which seems to clean up DataChannels which are still in use (thereby closing them).
  • 0.3.2 - Updated the library to align it with the latest WebRTC standards -- mainly changes in configuration objects.
  • 0.3.1 - Added 'firewall' option to firewall RTC requests.
  • 0.3 - Major refactor of internals and simplification of API, Firefox support, and respectable unit test coverage.
  • 0.2 - Public release
  • 帮助理解: P类问题就是指那些计算机比较容易算出答案的问题。 NP类问题就是指那些已知答案以后计算机可以比较容易地验证答案的问题。 1. “假设你参加一个盛大的宴会,想要知道里面有没有认识的人。宴会的主人对你说,你一定认识正站在甜点桌右边角落里的女士小龙女。你立刻扫向那里,发现他说的是对的。而如果他不告诉你这些,你就需要环顾整个大厅,审视过每一个人,然后才知道有没有认识的人。宴会主人的暗示,容易找

  • 首先要知道如何定义一个指针变量,即 int *p; 这个时候我们说p是一个指针变量,我们可以对它进行赋值,即 p = &a;(当然a是一个int型的变量,需要提前定义,即 int a;) 那么问题来了,“*”是用来干什么的呢? 这里呢,我们需要分两种情况来讨论这个“*”。 第一种情况,在定义的时候, * 是用来区分指针变量的,即有 * 则代表这个变量是一个指针变量。但要注意一点,这里的 *p本质上

  • 一、指针与指针变量 1、指针和指针变量是两个不同的概念,但要注意的是,通常我们叙述时会把指针变量简称为指针。 2、指针就是地址,地址就是指针,它是一个形无符号整型,一个整数,它的大小取决于系统是16 32 还是64位的 16/8=2byte 32/8=4byte 64/8=8byte. 3、指针变量其实是一个变量,只不过其存放的内容为地址,如 int* p,这个p是指针类型,它的值存的是地址。  

  • @author Jinxin Li Linux 命令中 -P与-p的区别 大P与小p的区别 p有path的意思,所以说肯定与路径有关 mkdir -p 创建多层目录 可以使用-p参数创建多级目录 $ mkdir -p realpath/realpath1/realpath2 $ tree realpath/#显示目录结构 --------------------------------------

  • 首先,P文件为了保护知识产权设计的一种加密文件,是不能查看的。 运行比较简单,和调用m文件方法一样。 下面是一些解释。 P文件是对应M文件的一种预解析版本(preparsed version)。因为当你第一次执行M文件时,Matlab需要将其解析(parse)一次(第一次执行后的已解析内容会放入内存作第二次执行时使用,即第二次执行时无需再解析),这无形中增加了执行时间。所以我们就预先作解释,那么以

  • (*p)[5]与*P[5]有什么区别,看代码 main() { char a[5]={'A','E','C','D'}; //数组指针 char (*p3)[5] = a; //在栈中产生一个大小为 5个char的空间 p代表的的是整个空间的首地址 printf("p3 is %x\n",p3); printf("*p3 is %x\n",*p3

  • 一,++p,p++ ++p是先对p自增,再使用p的值. p++是先使用p的值,再自增 二,*p++,*(p++) 两者相同 " * 和++ "优先级相同 自右向左结合,*p++可以看作为*(p++) 其中(p++)先使用p的值,再自增1 假设地址为0x00, *(p+1)则取0x00的地址值. 三,(*p)++ 先分析优先级,有括号,先计算括号内,即先计算(*p)得到X,再计算X++. 四,*++

 相关资料
  • 当我在网上做研究时,似乎人们也在这个堆栈中使用SQS,SNS会将信息放在SQS上,然后SQS会调用Lambda。 我想我想理解的是在这方面对SQS的需求。这增加了什么价值?换句话说,直接从SNS调用我的Lambda会失去什么?

  • .to( target:Object, duration:Number, vars:Object, position:* ) : * 添加一个TweenLite.to()动画到时间轴,相当于add(TweenLite.to(...)),以下两行产生相同的结果: myTimeline.add( TweenLite.to(element, 1, {left:100, opacity:0.5}) );

  • 我正在测试在服务器上设置一个Git(EC2-Linux,Amazon)。一切都很好,但我做了一件事,我不能复制,我想理解。 我正在遵循以下Git在服务器https://git-scm.com/book/en/v2/git-on-the-server-setting-up-the-server上的教程 我创建了4个用户进行测试,并在服务器上创建了他们的ssh密钥。(User Git)在/home/G

  • 描述 (Description) 如果你想打开浮动操作按钮酥料饼的点击,那么你可以使用floating-button-to-popover类。 例子 (Example) 下面的示例指定使用变形过渡(创建的具有平滑的动画内容的外观)在酥料饼的内容的呈现 - <!DOCTYPE html> <html> <head> <meta name = "viewport" content =

  • 一个无后端待办事项应用,数据用 LeanCloud 进行同步。 简介 这是一个无后端的待办事项应用,数据用 LeanCloud 进行同步,也是我的第三个 iOS 项目。 做这个项目的初衷是想比较全面地体现我的前后端水平,该同步算法从整理思路到实现 95% 的代码(意为接近稳定)花了两周时间,除思路外没有任何代码可以参考(反正我是没有找到... 界面设计来源于 DO ,部分素材和界面为本人设计。 该

  • to-markdown 是一个用 JavaScript 编写的将 HTML 文档转成 Markdown 格式的库。 示例代码: var toMarkdown = require('to-markdown').toMarkdown;console.log(toMarkdown('<b>Hello world</b>'));// Will output '**Hello world**' 在线演示:h

  • 问题内容: I have 10 jenkins job in folder . I have created a new sub folder in folder . How to move the 10 jobs from folder to the subfolder ? 问题答案: First, you need to install cloudbees folder plugin then

  • Returns subpath of a given element from given start and end lengths (only works for path elements) Parameters fromnumberlength, in pixels, from the start ofthe path to the start of the segment tonumbe