P2P – Share real-time data across Android and desktop AS3
sing native IP-only multicast feature available with Adobe AIR 2.0 and Flash Player 10.1 you can easly establish a connection and share real-time data between two or more clients over the same network (LAN).
The immediate advantage you can get from this tecnique is that you won’t need to use a dedicated server (like Flash Media Server, AFCS, and so on) to share real-time data across multiple clients.
Another cool stuff is that you can use P2P to share data between mobile Air for Android apps and desktop AIR applications, and in this post I’ll provide you a video demo and the source code to put in place this, getting you the fundamentals to build your own multiuser game or collaborative application.
What you can also do using this technology:
- Building real-time chats
- Collaborative whiteboards
- real-time multiusers games
- manage a desktop AIR application from your Android device: let’s think about an AIR Media Center on your TV managed from your mobile device; or moving a slide presentation on your laptop from your Android smartphone, and so on
- everything else needs to share real-time data across multiple clients and different platforms.
- Collaborative whiteboards
- real-time multiusers games
- manage a desktop AIR application from your Android device: let’s think about an AIR Media Center on your TV managed from your mobile device; or moving a slide presentation on your laptop from your Android smartphone, and so on
- everything else needs to share real-time data across multiple clients and different platforms.
Below, the video demo (no-sound) where I show you the final result.
Moving the movieclip on my Android device, I will move the clip on my desktop application too, and viceversa.
Moving the movieclip on my Android device, I will move the clip on my desktop application too, and viceversa.
Get the latest Flash Player to see this player.
Following the ActionScript source code (full-commented) to build the Air for Android application in Adobe Flash Professional CS5.
Document class:
To test this sample you should use the previous class as document class of a new Air for Android Flash file (using Flash Professional CS5) and create a movieclip on your stage setting its instance name to ‘mc’ (see image below):
To verify if P2P is working, let’s run two instances of the application on your desktop and drag the movieclips.
If it works, install the application on your Android device, open an instance on your desktop and move the movieclip on both platforms to see if clients are connected.
If it works, install the application on your Android device, open an instance on your desktop and move the movieclip on both platforms to see if clients are connected.
Remember to set the android manifest permission to allow internet connections on your android xml-descriptor file:
Comments
Post a Comment