PDA

View Full Version : Send data to non-connected GK players?




ArtOfWarfare
Sep 8, 2012, 02:11 PM
Does anyone know of any ways to send data between players who haven't yet decided to connect to one another?

Here's what I'd like to have happen:
Players hit the multiplayer button. On the multiplayer screen, they see a list of hosts, and as the player is still trying to decide which host to join, they can see information like which level the host is going to be playing and the names of clients that have joined the host so far.

Thus far, all I've been able to do is make it so the player looking for a host can see the host's name. I've tried using methods like GKSession's sendDataToAllPeers, but I've found that it only sends that data to all of their connected peers.

I'm thinking the easiest way of achieving what I want might be done by having the host change its name to reflect the additional data I'd like it to have. So, for example, if the host is called "Player A" and a client wants to join with the name "Player B", the host would change it's name to "Player A + Player B", and then the clients would recognize that they need to show Player A as a host and Player B as the host's client.

An issue with that, however, is that a displayName is immutable while the GKSession is running. So I'd have to make the session restart itself each time it wants to change it's name, which means the connections to the existing clients would have to be rebuilt.

Before I undertake the challenge of making the whole displayName changing system work, I thought I'd ask here, does anyone know of an easy way to send out data to non-connected GK players?

Could I perhaps make a subclass of GKSession that is able to share more than just its displayName, peerID, sessionID, and sessionMode with non-connected instances? (I don't see how that would be possible without having the source code for GKSession... I'd have to modify some private method, I imagine.)



bencallis
Oct 10, 2012, 11:31 AM
Did you get anywhere with this?

I am wanting a build an application which allows users to share PDFs. Rather than just show the severs name I would like to show the PDF name, number of pages, size etc.
The only possible solution I have come to think of is to make the clients auto connect to the available servers one by one and ask for the information. Then disconnect.
Whilst this seems like it may work it leads to many potential problems such as synchronisation issues. What happens if a client taps a file which it wants to receive when it is actively connected to another server to receive the file information?

I would be interested to know how you tackled this issue. :)