Game Development Reference
In-Depth Information
ers and is actively searching (as is the case with matchmaking systems), and so
players can sit and talk while the other players are found.
Whatever you choose, remember that they are there to play and you want to minim-
ize their downtime as much as possible. If they're sitting forever in lobbies then they
won't find the game fun and will quit playing. The best option is a game that allows
players to drop in at any time; however, this isn't always possible and you need to
choose what is right for your game.
Using the PeerFinder
One option on Windows 8 for connecting, if you don't want to set up a master server
or UI for entering an IP address, is to use the PeerFinder API. This uses Wi-Fi and
Bluetooth to find nearby machines to connect to and allows you to advertise and es-
tablish a connection with a few simple calls.
PeerFinder itself is part of the Proximity APIs, which also includes the ability to estab-
lish connections or open applications using the Near Field Communication ( NFC )
sensor that may be present in some devices.
Note
Proximity is a new API in Windows 8 that allows for easy operation and connec-
tion of devices that are physically close to each other. The focus of this API is to
enable scenarios where two devices can easily connect and communicate using
Bluetooth, NFC, or Wi-Fi Direct. By having a consolidated API, developers don't
need to put a lot of effort into supporting the different communication types.
To begin working with PeerFinder, we need to start advertising that we are accepting
connections. This is done with the PeerFinder::Start() static method. This call
is also required if you want to search and connect to another peer, so you could
enable a peer-to-peer situation where the game automatically starts advertising and
then the players can decide who connects. This is shown in the code snippet that
follows:
Search WWH ::




Custom Search