Closed kenianbei closed 10 years ago
listAllPeers
has to contact the server, so it's asynchronous. I'm
hesitant to document it just yet, because I'm still looking into how to
best implement this. There's an example usage in jquery.peer:
https://github.com/michelle/jquery.peer/blob/master/lib/jquery.peer.js#L327
Michelle
On Tue, Mar 18, 2014 at 8:15 PM, kenianbei notifications@github.com wrote:
I'm not quite clear on how listAllPeers() is used, it seems to expect a callback rather than just returning a list. Can you post an example of usage?
— Reply to this email directly or view it on GitHubhttps://github.com/peers/peerjs/issues/173 .
Thanks, I had no idea you had a jquery wrapper, wish I'd known 3 months ago :)
Haha, it's not done yet :).
Michelle
On Tue, Mar 18, 2014 at 9:02 PM, kenianbei notifications@github.com wrote:
Closed #173 https://github.com/peers/peerjs/issues/173.
— Reply to this email directly or view it on GitHubhttps://github.com/peers/peerjs/issues/173 .
is the method listAllPeers implemented on the server yet? if so what's the correct way to use it? Please forgive me, I'm a newbie...
start your own server with the option allow_discovery: true
, I am using express, that is something like:
var server = app.listen(8080);
app.use('/peer', ExpressPeerServer(server, {
allow_discovery: true,
debug: !!process.env.DEBUG
}));
i'm doing that:
var ExpressPeerServer = require('peer').ExpressPeerServer;
var options = { debug: true, allow_discovery: true }
// create a http server instance to listen to request var server = require('http').createServer(app);
// peerjs is the path that the peerjs server will be connected to. app.use('/peerjs', ExpressPeerServer(server, options)); // Now listen to your ip and port. server.listen(9000, "localhost");
var idList = server.listAllPeers;
app.get('/peerjs/ids', function (req, res) { return res.send(idList); });
this is my code.
But even when the app is running I get "undefined" object when i try to "console.log(idList)"
What am I doing wrong?
Haven't fully tested it myself, but listAllPeers is a method in the client library not on the server. AFAIK set allow_discovery: true on the server and try calling listAllPeers on the client https://github.com/peers/peerjs/blob/master/lib/peer.js#L457
thanks!!!!
I'm not quite clear on how listAllPeers() is used, it seems to expect a callback rather than just returning a list. Can you post an example of usage?