Behind The Scenes: Engineering Mobile Apps That Require P2P, Real-Time Sharing & Broadcasting On Same Wi-Fi
The last few years have witnessed an explosive growth in the mobile landscape. As hand-held devices and wireless communications continue to evolve, mobile P2P (Peer-to-Peer) applications have emerged as the new kids on the block.
Current P2P mobile apps are widely used across sectors like education and gaming to elevate the existing experience of users. However, designing and building such genre of apps can be like venturing into tricky waters.
A little bit of brief before we dive in
To put simply, mobile P2P applications help teams and groups collaborate by helping them share real-time information to achieve a specific goal. As ScienceDaily, very aptly explains, P2P apps allow people to connect and work together without having to go through a central communications unit first.
Consider this to understand how P2P applications are actually redefining the education domain.
Think of a classroom where everyone is equipped with a tablet having a P2P app. Each tablet is connected with each other over Wi-Fi. The teacher starts the app, selects the subject and opens up a chapter from an e-book. Imagine, all this activity being performed on individual tablets of students too!
Any action that the teacher undertakes is shown to the students in real-time.
Be it white-board collaborations or sending out quizzes, P2P applications have turned out to be the next-generation tools for people who want to collaborate and team up in a more efficient way.
Options for building P2P applications
Building these applications is highly complex. There are a couple of ways using which you can engineer these apps:
- The data from sender’s app goes to the server and the receiver’s app has to constantly send requests to server to ensure it receives the updated information. In this approach, the receiver’s app constantly looks up for server update to see any new information is to be received. The problem with this approach is that the device battery continuously gets drained.
- Next approach is to make the use of Google Cloud Messaging (GCM). Herein, the app sends data to server which then sends it to GCM, which in turn broadcasts the information to users. Herein, the battery consumption is optimized as the receiver’s app does not have to continuously send requests to server to get updated information. GCM sends in information only when the sender’s app initiates an action or performs a task.
Examining closely, you will notice that there is a server involved here. Pushing data to the server and pulling back the updated data from server delays real-time sharing.
This approach does not work effectively with applications that involve real-time sharing such as in a classroom scenario as explained above. Screens cannot be shared amongst teachers and students if this approach is followed.
When it comes to mobile apps and specifically P2P applications, user experience is something which you cannot compromise on. The real-time sharing of information has to be seamless.
A second’s delay can disrupt communication and ruin the whole experience.
Is there an alternative
Luckily, Qualcomm came with up with a brilliant solution to this challenge – AllJoyn.
An open source framework, AllJoyn, provides an object-oriented approach to make peer to peer sharing easy, avoiding the need to ever deal with lower level network protocols and hardware. There is no server involved here.
AllJoyn makes it easier to develop applications that require proximity based device to device communication on the same network. Its architectural topology is like a virtual bus that connects multiple AllJoyn daemons and links including bus attachments.
The virtual bus connects multiple AllJoyn receivers’ service in the background. Sender uses a process of advertising to broadcast their existence, which then connects to other AllJoyn daemon’s, offloading the work to establish the connection (locally or over Wi-Fi or Bluetooth).
Once the connection is established between sender and one or multiple receivers, receivers are ready to get the signals. They can accept simple and complex data types as arguments and can return. This data will is transferred in fraction and can be processed as required.
The way to go
In nutshell, since no server comes into play while using AllJoyn Framework, P2P apps function seamlessly sharing real-time information in fractions of a second. This helps deliver the ultimate user experience.
So, if you are thinking of developing a multiplayer-game with peer-to-peer, cross platform capability or an app that requires multi-screen sharing, AllJoyn is your answer!