p 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
p 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
p 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 View license
开发语言 C/C++
操作系统 跨平台
软件类型 开源软件
所属分类 程序开发网络工具包
开源组织
地区 不详
投 递 者 首席测试
适用人群 未知
收录时间 2021-11-30

软件简介

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 channel to 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
展开阅读全文

代码

评论 (0)

加载中
更多评论
暂无内容
发表了博客
2019/08/24 15:38

**p,*p和&p使用有感

*p两种使用情况: 1.定义指针变量,如char *p;这里p是一个变量,单单在这一点上与int a 无差别;但p这个变量特殊在其中只能存地址。 引申:对于char **p,p中存一个地址add1,add1对应存储区存放add2,而add2地址对应存储区才存放有真正的data;如下图1所示: 2.*p,用来取p中所存地址对应存储区的数据,如上图2所示。 例如:主函数main中有char *p,p=。。。令p中存放某一内存首地址。这时调用子函数,若想在子函数fun中修改p...

0
0
发表于云计算专区
2015/05/11 11:08

This is the first part of a two p

Candidate for Texas Lieutenant Governor David A. Grimes Describes the Past and Present State of Abortion Care in the USFebruary 09 11:35 AM EST The Tejano daughter, wife, mother, grandmother, pharmacist, and politician seeks lieutenant governorship on a ticket with Texas gubernatorial candidate Wendy R. Davis. (Photo : Facebook/Leticia Van de Putte) Van de Putte's grandfather, grandmother, aunt...

0
0
发表了博客
2013/11/20 21:34

int *p; scanf("%d",p);问题

void main() { int *p=NULL;//定义整型指针变量,是个野指针,可能指向任意位置 printf("Input a number:"); scanf("%d",p); return ; } 定义整型指针变量p后,没有指向任何有实际意义的地址,则它还是一个野指针,很危险,可能破坏其他有用的数据。 可改成下面的形式: void main() { int m=0; //定义整型变量 int *p=&m; //定义整型指针变量p,使其指向整型变量m的地址 printf("Input a number:"); s...

0
0
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
暂无内容
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部