2

I'd like to get peers' data who are connected with gunDB. Although I tried to create and manage my own peer list from wire. But I think if gunDB already has the peer list, using it would be better than mine.

So could you please advise how I can get the peer list from the gunDB server?

I checked the peer list here which creates peer id and pushes peer to peer list(opt.peers). but I have no idea how I call the list from outside like on my server scripts.

Please give me advice about that!

huhsame
  • 73
  • 1
  • 9

2 Answers2

2

@huhsame I'll have to answer this question in more detail later, but for now just gonna paste some code to get you started:

gun.back('opt.peers')

or

gun._.opt.peers

I recommend the API approach rather than the "internal" _ approach.

marknadal
  • 7,534
  • 4
  • 25
  • 22
0

@marknadal

Sorry I am late because it was a Lunar new year holiday

I tested gun.back('opt.peers') (gun-peers) as you answered with my peer list (huh-peers) which I made using WebSocket Wire and Mesh.hi in gun. I found some problems so I'd like to share it with you.

  1. result at client
  2. result at the server

1. the result at client

I tested it on four browser instances - left(chrome), middle(chrome), right(opera), safari(safari) - client peer list - start

  • gun-peers prints id by WebRTC of each peer including the server - gun-peers first try. I think it is more useful than huh-peers which is got from the server when the page is served because it can check other peers whom I connected with currently.
  • If I refresh some of the clients, gun-peers prints peer list including the previous peer information before refreshing - refreshing vedio. As a result, at the right one which is refreshed last, gun-peers prints right peer list. But at the left and the right one, previous peer information is printed - after refresh
  • If I connect the same space at Safari which doesn't work WebRCT, gun-peers prints just the server at safari and at others(left, middle and right) prints without the information of safari - with safari

2. the result at server

there are some results in each case in 1. the result at the client.

  • gun-peers prints id by WebSocket unlike at client printing id by WebRTC, and it prints just N-1 peers - comparison gun-peers and huh-peers at server
  • In the safari case like as I mentioned at 1.4, the number of gun-peers at the server is increased even though it doesn't print at the client side as I mentioned. But gun-peers still prints only N-1 peers as I mentioned 2.1 - at server with safari

So I decided to use huh-peers temporarily. I am wondering why there is a different result like that. even though huh-peers is based on GunDB connection data.

Please take a look at it. Thank you :)

huhsame
  • 73
  • 1
  • 9