Reputation: 481
How can i use hotspot connection between 2 devices and send messages between each other in AIR/AS3 application?
In fact, I want to make a multiplayer game with this method
Upvotes: 2
Views: 89
Reputation: 4809
There are mainly two ways to allow people on the same HotSpot to play togother, with AIR, depending on the HotSpot behaviour.
1st way: when the HotSpot is not configured with "Private VLAN" (Private VLAN blocks network frames between nodes connected to the same HotSpot).
You can use UDP broadcast (or multicast) packets: these packets are sent to every node (or multicast group member nodes) on the same layer 2 network (i.e. the HotSpot network). But AIR does not support this type of network communication: no AIR API is able to generate such packets. So, you need to create an Air Native Extension (http://www.adobe.com/devnet/air/native-extensions-for-air.html) to make native calls to the underlying operating system. For instance, with AIR on Android, you can make native calls to the Java subsystem and use the java.net.DatagramSocket class.
2nd way: when the HotSpot behaviour is "Private VLAN".
You just have to create a Rendezvous Point on the Internet: this is a server that each player connects to, and this server switches messages from each player to other ones. To let people on the same HotSpot play together, you need to create some arena on which users on the same HotSpot will connect to. To connect to the Rendezvous point, just use the mx.rpc.http AS3 package. If you are using FlashBuilder, you can automatically generate stubs that call this package, you only have to give a description of the parameters and URL of the Rendezvous point web services.
Upvotes: 1