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])
特此免費授予任何獲得本軟體和相關文件文件(「軟體」)副本的人不受限制地使用本軟體,包括但不限於使用、複製、修改、合併的權利、發布、分發、再授權和/或銷售軟體的副本,並允許向其提供軟體的人員這樣做,但須滿足以下條件:
上述版權聲明和本授權聲明應包含在本軟體的所有副本或主要部分中。
本軟體以「現況」提供,不提供任何明示或暗示的保證,包括但不限於適銷性、特定用途的適用性和不侵權的保證。 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE軟體.