Originally posted on the cownado.com blog.
While now both Bluetooth and Multipeer Connectivity are viable options for implementing local multiplayer games, they both have a common disadvantage: You cannot have one player using an Android device connected to a player using an iOS device.
The solution to this problem is to implement WiFi networking, using open protocols that are recognized by both operating systems, so let's take a look at the technologies involved:
The first technology is of course TCP/IP, so a server would create a TCP socket, and the client would connect to that socket, but in order to do that, it must know both the IP address and the TCP port of the server.
In order to make the IP address and the TCP port known to all the devices on the network, the server can publish those information using a technology called Zeroconf (aka Bonjour).
Ok, now let's see how to implement those technologies using Cordova:
Let's start with the TCP sockets:
- Chrome Apps for Mobile are no longer being actively developed
- I already had bad experiences with Chrome Apps for Mobile in the past (The bugginess of cordova-plugin-chrome-apps-bluetoothsocket is the very reason why I made cordova-plugin-networking-bluetooth)
But wait a minute: who said that we need raw TCP sockets?
Now let's move on to the Zeroconf part, and it turns out that there is the cordova-plugin-zeroconf, also by Becvert Prod.
By using these plugins you can implement a multi-platform multiplayer game, but it turns out that using correctly these technologies is much harder, and has much more implications than it may initially seem.
We are going to see these implications in the next blog post, so stay tuned.