Help with multiplayer?

Hello, everyone.

I was originally working on a basic module to allow local Wi-Fi multiplayer in a game I'm working on. Unfortunately, I tried as hard as I could, but I couldn't get it to a level acceptable enough for me to consider using it.

Instead, I've taken what little work I've done (heavily inspired by the work of Matthew Pringle; see http://developer.anscamobile.com/reference/index/networkrequest#comment-19090) and tried to simplify it a bit. I've made a Git repo with a very simple example of my idea. But be aware:

- This will not work in a production app. I'm only posting this to see if anyone with more experience could take a look and (by some random chance) be inspired to write something better

- The method I wanted to employ may not be the best way to go about this...and even if it were, we'd need to access to the device's IP address. I've tried so many crazy things to get the local IP...or at least the local subnet, but to no avail.
(Ansca, by the way...would it be possible to have access to the IP anyway? hehe Any of these help?
http://bit.ly/ieYMfh
http://bit.ly/jWL8dT
http://bit.ly/jmnvky)

- The example in the repo was put together quickly...and it's not documented well. I tried to make the module simple enough to use, but I probably complicated things by including this example. hehe If you want to try it out, build for your phone and also run on the Simulator (or two devices, I suppose). Your Wi-Fi network must be 192.168.1.x. Touch "Host" on one, "Join" on the other...and after the connection is finished, press "Send" to send "Hello" to the other device.

Here's the repo if anyone's interested in taking a look:

https://github.com/TheOddLinguist/lump

If you have any questions, feel free to ask. Again, this isn't something you can use right now; it's not functional enough. However, if you do decide to take a look, assume this were functional and be aware of the following known issues:

- The current implementation would only allow for 1v1; it could certainly be tweaked to allow for more...but that might be quite the task.
- This does not support notification of disconnect; if your opponent leaves, you'd have no idea. I had some ideas on how to handle this, but my connection method may not allow for that in an easy fashion.
- There are probably other things this can/can't do. Again, if Ansca can give us the IP address, some form of this code may be usable...if which case, feel free to do what you wish with it. If you do come up with something, let me know though; I'd like to use it myself. hehe

Thanks for your time; I hope this inspires someone to make something awesome.

Sincerely,
Christopher David YUDICHAK

While I'm here...

Ansca, is there actually any chance of getting device IP or perhaps Zeroconf/Bonjour access in Corona? I, obviously, don't know how your APIs are built...so perhaps what I'm asking for is impossible. ...but I figured I'd ask and see if this is even a possibility before asking where it sits on your list. hehe

Thanks for your time.

Christopher

Hi TheOddLinguist,

the demo from gibthub actually works between iPhone 4 and/or iPod 2nd and/or Corona Simulator and/or Nexus One. Nice one. Hopefully, you get the information about getting the IP soon :-)

Best
-- Jörg

views:1489 update:2011/9/29 9:22:17
corona forums © 2003-2011