简体   繁体   中英

Get all connected peer(Peer.js)

How can i get all connected peers if i have simple server:

    var port = 9000;

var express = require('express');
var app = express();
var ExpressPeerServer = require('peer').ExpressPeerServer;

app.get('/', function(req,res){
    res.send('server OK');
    //console.log(ip.address());
});

var server = require('http').createServer(app);

app.use('/peerjs',ExpressPeerServer(server));

server.listen(port,'0.0.0.0');

and client:

var peer = new Peer(
        {host:"hostname",
         port:9000,path:"/peerjs",
         debug:3,
         config:servers, 
         });

i use peerjs lib. Thank in advance!

Peer.js has method listAllPeers on the client side. And you can use it if you add allow_discovery: true parameter in options on the server side.

This should help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM