Well, I have some pretty good news. I am now working on my iPhone/iPod Touch game with a friend. He is a very talented graphics designer which is going to help me GREATLY!!! I am very excited.
At the moment I am not going to be discussing game specifics, but I did want to let some of the details loose. The game is a PvP (player verses player) head-to-head type game. I am currently playing around with scenarios that will synchronize the game events on both of the players, but I do know so far that I need to use sockets to do the communications. The iPhone is basically a scaled down Mac OS. Knowing this and that the Mac is basically a modified BSD Unix system I screamed and ran around my yard for a few hours yelling, “How ever will a .net programmer figure out BSD sockets?” Well, after I calmed down, I did some searching and found a nice wrapper for the BSD sockets called AsyncSockets. You can d/l it from here http://homepage.mac.com/d_j_v/FileSharing4.html. The weird thing is just how the BSD sockets work compared to net socket programming. They are based on a system that uses a run loop. Each iteration of the run loop checks to see if an action is needed, or an event needs firing. This is not at all how it works in .net, but nothing is really as easy as .net is (when the IDE isnt crashing <grin>).
If you are having trouble with the AsyncSocket sample project you are not alone. However, I found a really easy way to solve the issue. I was getting some weird error about Jam being depreiciated. I know I listen to some old music, but I am sure my Jams are not depreiciated (that was really bad, even for me). To make it work, just create a new xCode project and add the existing files from the sample project, in other words, do not use the provided project file, just import the 2 class files from it. Add the missing framework (I think it was CoreServices.framework) and it will build just fine.
I actually built a sample app that ran the server on a background thread, and the client on the main thread. Then I had the client connect to the server and pass a message through the pipe and back. So, I had an iPhone simulator talking via a pipe to itself. I do lead a boring life dont I?
Next time, I will discuss some things I learned about threading on the iPhone and how to marshal calls from the background thread to the main thread.
I was going to write a “iPhone Dev for .net develoeprs”, but it’s so different, that I think I’ll just use this blog to talk about things I discover and provide some code samples along the way when it warrants.
-Jeff
Posted by savij
Posted by savij