Archive for NSStream

In the first version of the communicator class we were only handling messages that were smaller then 1024 Byte.

To allow it to receive larger messages we need to know when an individual message is finished. Therefore we have to add a unique specifier to the string our server sends, for example “\r\n”. Then we can simply add an “NSMutableString msgBuffer” to our class and another method between the “- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode;” and the “- (void) handleInput: (NSString*)string;” method that does the following:

Objective C professionals probably realize that I don’t like “autorelease”. The string-argument is supposed to be retained, as is the argument to “[self handleInput]”. I know an object is supposed to be released where it was retained but my original string was retained in “handleEvent” and released in “handleInput” and I didn’t want to change those two methods. This code would not be consistent with the older post otherwise.

When I was learning how to show Models with OpenGL I had the great Tutorials by Jeff Lamarche to help me with. But now that I was facing the development of a client-server pattern to build a multiplayer experience for my game I was stuck, because I couldn’t find any good help here.

Maybe there are others out there who’d appreciate some clarification and sample codes about that, so I’m trying to post something that I would have liked to use, when I was starting with the Topic.

Blog about the development of an iPhone App inspired by the Walking in Stations Minigame "SecWars" of the MMORPG EVE Online.
Code Examples and ramblings about Objective-C, OpenGL and assorted programming topics included.