2

so initially we have this code:

browser = MCNearbyServiceBrowser(peer: peer, serviceType: "sample")

which sees all advertisers with the service type "sample" right?

What if I want to see all advertisers without knowing their service type? How can I do this programatically?

Thanks for any reply.

Whirlwind
  • 14,286
  • 11
  • 68
  • 157
Sylvent
  • 66
  • 6
  • It's not clear why you would want to do that. The service type allows you to ensure that the peers at either end of the connection will exchange data in a way they both understand. – Keith Coughtrey Jul 03 '15 at 01:15
  • @KeithCoughtrey you see I am building a chat app using MPC. I want it to have a "public chatroom". Now the problem is that if a user will create a public chatroom, it would have a different service type then all the other user will not see the room because of their browser. Then that chatroom will be private. You see what I am getting at? If any of these is still unclear, just let me know. Btw, thanks for the reply. – Sylvent Jul 03 '15 at 03:21

2 Answers2

1

Normally the service type is used to allow you to connect to peers that are running the same application, so it my be "my-chat-app" for example.

When a peer starts browsing for others to connect to it hears any advertising peer for the specified service type, which generally means those running the same app.

When a peer starts advertising its interest in joining a session it may provide discoveryInfo - a dictionary of key-value pairs that are made available to browsers.

The browser can use the discovery info to decide whether to issue an invitation. The chat room in question could be included in this info.

Keith Coughtrey
  • 1,386
  • 13
  • 17
0

I think serviceType is identifier of App using MPC. So user of your App should not define serviceType, developer(you) decides it. If you want to create like a group chat room, you create a procedure to do.

ketancho
  • 335
  • 1
  • 2
  • 6