WiFi P2P , which complies with the WiFi Alliance’s WiFi Direct™ certification 2 3 program, is a relatively new addition to wireless communications systems. It is now supported in Android operating system (since version 4.0). In theory, WiFi Direct offers advantages for ad hoc communications between mobile apps. A key goal of this project was to evaluate the ability of WiFi P2P for interconnecting mobile apps by using a
common game suitable to mobile screens and devices.
The application allows the user to interconnect two devices using WiFi P2P and play the classic hangman game. The players search for devices that already have the game installed using WiFi P2P service discovery and when it finds one, it can send a connection request to connect with the peer device. The peer device can choose to either accept or decline the connection request.
When the two devices are connected, the game starts and the players can establish a socket connection using each of their device configurations and exchange messages with each other. The players take turns in guessing words.
The player who initiates the connection goes first and gets to specify a word, which the second player has to guess, and a hint(displayed to player 2). The second player tries to guess the letters of the word and player 1 decides whether the letter is in the word or not. With every wrong guess, a part the man is hanged. The game ends if the second player guessed the word or if the hangman diagram is completed. The total score is displayed at the end of a game session. Any player can end the game session at any time.
This paper illustrates the software architecture, the method of adding WiFi direct to your Android application, an understanding of a few pieces of code from the project and lastly learnings and future scope. A key finding of this project is that the application needs to run in the foreground in both devices while trying to establish a connection with a peer device.
Source: Loyola University Chicago
Author: William L Honig
Download Project