Communication between iOS devices

Are there any examples of how to write a game with the Defold engine that allows two players on different ios devices (on the same LAN) to play a peer-to-peer multiplayer game?

1 Like

No, not specific to Defold, but since you’d achieve this using the LuaSocket implementation bundled with Defold I guess you could look at any LuaSocket example that shows how to do discovery using UDP and then connecting using a socket. If time permits I can maybe create an example of this during the week, but I can’t make any promises!

3 Likes

Thanks. Would love to see an example if you have time.

2 Likes

Would bluetooth communication require a different technique?

1 Like

If I were you I would do it server based. Then make it easy for one player to join the other player’s lobby by entering a code for example to pair up the devices to be able to join each other when they want to. Use websockets.

What kind of game? More action requires lower latency and resources.

1 Like

There is no support for Bluetooth in Defold.

1 Like

@puzzler: I’ve created an example showing peer to peer discovery using LuaSockets. The example should be run on two devices/computers on the same network. One should select to Broadcast while the other should select Listen. The client that selects Broadcast will create an UDP socket and broadcast a message and the listening client will listen for the same message, and when received invoke a callback with the broadcasting device’ IP and port.

Once you have the IP and port of another device you can implement device to device communication of some kind (UDP, TCP, HTTP) but that part is not included in the example.

You can find the example here: https://github.com/britzl/publicexamples/tree/master/examples/peer_to_peer

5 Likes

Much appreciated. Thanks for posting this.

1 Like