appnet.link
1.0.0
appnet.link依赖于nodejs-httpp,请从repo nodejs-httpp构建它
安装appnet.link模块
npm i appnet.link
设置您自己的AppNet.link后端控制器服务参考AppNet.link-controller
1. create AppNet client
var APPNET = require('appnet.link');
var nmcln = new APPNET({
usrinfo: {domain: '51dese.com', usrkey: 'dese'}, // fill usrkey. And, 51dese.com is only useful domain by now
});
nmcln.on('ready', function(){
console.log('appnet.link ready with vURL:'+nmcln.vurl);
// ...
});
2. hook node.js web server in peer. Websocket server is supported with wspp module as well. This is an express App example. file peerweb.js.
var express = require('express');
var WebSocket = require('wspp').wspp;
var WebSocketServer = WebSocket.Server;
var APPNET = require('appnet.link');
var nmcln = new APPNET({
usrinfo: {domain: '51dese.com', usrkey: 'dese'}, // fill your usrkey. And, 51dese.com is only useful domain by now
});
nmcln.on('ready', function(){
// 2.1
// create your express App
var app = express();
app.use(express.directory(__dirname + '/public'));
app.use(express.static(__dirname + '/public'));
app.use(function(req, res){
res.end('invalid path');
});
// hook app on business server
nmcln.bsrv.srv.on('request', app);
console.log('Now access your web server via URL:'+nmcln.vurl);
// 2.2
// create your websocket server
var wss = new WebSocketServer({httpp: true, server: nmcln.bsrv.srv});
wss.on('connection', function(client){
console.log('new ws connection');
});
console.log('Now connect to your websocket server via URL:'+nmcln.vurl);
});
3. STUN/TURN session setup case, please refer to demos/clnt.js
Look on demos/
(麻省理工学院许可证)
版权所有 (c) 2012 年至今 Tom Zhou([email protected])
特此免费授予获得本软件和相关文档文件(“软件”)副本的任何人不受限制地使用本软件,包括但不限于使用、复制、修改、合并的权利、发布、分发、再许可和/或销售软件的副本,并允许向其提供软件的人员这样做,但须满足以下条件:
上述版权声明和本许可声明应包含在本软件的所有副本或主要部分中。
本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途的适用性和不侵权的保证。在任何情况下,作者或版权持有者均不对因本软件或本软件中的使用或其他交易而产生或与之相关的任何索赔、损害或其他责任负责,无论是合同、侵权行为还是其他行为。软件。