iPhone bugs

Post here all your questions related with the SmartFoxServer iPhone API

Moderators: Lapo, Bax

Dest987
Posts: 12
Joined: 21 Apr 2009, 01:37

iPhone bugs

Postby Dest987 » 21 Apr 2009, 15:36

In handleCreateRoomError the line:
NSString *errMsg = [[[doc nodesForXPath:@"./msg/body/room/e" error:&error] objectAtIndex:0] stringValue];
is missing an @ sign so it will never actually find the e in the xml. It should be:
NSString *errMsg = [[[doc nodesForXPath:@"./msg/body/room/@e" error:&error] objectAtIndex:0] stringValue];

In handleJoinOk, if you are joining a room that was just created (happens a lot when you create a game room) the currRoom variable will never get set since it uses getRoom:roomId to get it but the room list hasn't been updated yet. Not sure if this is necessarily a bug but it is very confusing since all the code looks like it would return the room.
Dest987
Posts: 12
Joined: 21 Apr 2009, 01:37

Postby Dest987 » 21 Apr 2009, 16:29

NSObjectAddition has warnings in it. The warnings make it look like it would always return nil but I haven't tested that.
Dest987
Posts: 12
Joined: 21 Apr 2009, 01:37

Postby Dest987 » 22 Apr 2009, 03:13

In INFSmartFoxUser.m both setPlayerId and getPlayerId use _id(the user id) instead of _pId (the player id). This causes you to lose your valid user id in several cases (like on handle user entered room)
Dest987
Posts: 12
Joined: 21 Apr 2009, 01:37

Postby Dest987 » 22 Apr 2009, 03:28

In handlePrivateMessage the parameters being sent to onPrivateMessage will often stop after the sender param. This is because sender can be nil when you can't find the sender in a room, and the NSDictionary::dictionaryWithObjectsAndKeys: function stops at the first nil. Putting sender to be the last parameter fixes this.

Should probably check the rest of the functions to make sure you will never get a nil value that kills the following parameters.
User avatar
cemuzunlar
Posts: 47
Joined: 26 Dec 2008, 00:45
Contact:

Re: iPhone bugs

Postby cemuzunlar » 23 Apr 2009, 10:59

Dest987 wrote:In handleCreateRoomError the line:
NSString *errMsg = [[[doc nodesForXPath:@"./msg/body/room/e" error:&error] objectAtIndex:0] stringValue];
is missing an @ sign so it will never actually find the e in the xml. It should be:
NSString *errMsg = [[[doc nodesForXPath:@"./msg/body/room/@e" error:&error] objectAtIndex:0] stringValue];

It will be fixed with the next release.

Dest987 wrote:In handleJoinOk, if you are joining a room that was just created (happens a lot when you create a game room) the currRoom variable will never get set since it uses getRoom:roomId to get it but the room list hasn't been updated yet. Not sure if this is necessarily a bug but it is very confusing since all the code looks like it would return the room.

If you didn't use:

<DisabledSysEvents>
<event>onRoomAdded</event>
</DisabledSysEvents>

you should get a "new room added" event before "join ok" event.

Dest987 wrote:In handlePrivateMessage the parameters being sent to onPrivateMessage will often stop after the sender param. This is because sender can be nil when you can't find the sender in a room, and the NSDictionary::dictionaryWithObjectsAndKeys: function stops at the first nil. Putting sender to be the last parameter fixes this.

It will be fixed with the next release.

Dest987 wrote:In INFSmartFoxUser.m both setPlayerId and getPlayerId use _id(the user id) instead of _pId (the player id). This causes you to lose your valid user id in several cases (like on handle user entered room)

It will be fixed with the next release.

Thanks for reporting.
Cem Uzunlar
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 23 Apr 2009, 11:14

We're currently going to release an new SFS PRO update, it should be in the next few days. After that I will also publish an updated version of the iPhone API provided by Cem which includes a new example

stay tuned :)
Lapo
--
gotoAndPlay()
...addicted to flash games
Dest987
Posts: 12
Joined: 21 Apr 2009, 01:37

Postby Dest987 » 30 Apr 2009, 16:46

In handleUserLeaveRoom you get the user name but then when you remove the user from the room right after that, it destroys the user name. Need to retain the user name until after you are done calling the callback function.

Also, how do I get rid of the warnings in NSObjectAddition.m. I'm getting these:
Line Location NSObjectAddition.m:22: warning: passing argument 1 of 'stringWithUTF8String:' makes pointer from integer without a cast
Line Location NSObjectAddition.m:17: warning: passing argument 1 of 'stringWithUTF8String:' makes pointer from integer without a cast
Line Location NSObjectAddition.m:17: warning: implicit declaration of function 'class_getName'

Is that #if (TARGET_OS_IPHONE) supposed to be if NOT TARGET_OS_IPHONE? Seems like class_getName is a mac only thing maybe?
stager
Posts: 12
Joined: 06 May 2009, 11:28

Postby stager » 06 May 2009, 11:52

Hello!

I think that there is a problem in stream:handleEvent:
(INFSmartFoxiPhoneClient.m line 453-...). I constantly get unhandled exception if server stops while my client is connected. In this case -1 is returned by read:maxLength: at line 529 and this case is not handled properly. This problem can be fixed by applying this patch, but I'm not sure that it is fully correct fix. May be similar problem exists in some other methods... Here is simple fix:

Code: Select all

diff -r b94d94e7d202 Classes/SmartFox/INFSmartFoxiPhoneClient.m
--- a/Classes/SmartFox/INFSmartFoxiPhoneClient.m   Wed May 06 13:29:16 2009 +0300
+++ b/Classes/SmartFox/INFSmartFoxiPhoneClient.m   Wed May 06 15:45:58 2009 +0300
@@ -525,9 +525,15 @@
 //         NSLog(@"Event type: EventHasBytesAvailable");
          
             uint8_t buf[1024];
-            unsigned int len = 0;
+            NSInteger len = 0;
             len = [(NSInputStream *)stream read:buf maxLength:1024];
          [self debugMessage:[NSString stringWithFormat:@"Read directly from inStream len:%ld", len]];
+           
+            if (len < 0) {
+                [self handleSocketDisconnection];
+               
+                break;
+            }
          
             if (len) {
             int start = 0, i;



Sorry, code is reformated by forum :) , but I think it is clear what is done: type of "len" changed to NSInteger and if len < 0, handleSocketDisconnection is called. By the way, it looks like negative value can be returned if some other error occurs (see CFReadStreamRead documentation).
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 May 2009, 13:30

Thanks for reporting.
We're currently working on these fixes and we're going to release and update next week including a new iPhone game Example
Lapo

--

gotoAndPlay()

...addicted to flash games
stager
Posts: 12
Joined: 06 May 2009, 11:28

Postby stager » 06 May 2009, 15:30

Hello!

This time I'm not sure if this is a bug or not, but my app frequently got an EXC_BAD_ACCESS in INFSmartFoxiPhoneClient dealloc call. The line which cause a signal is [_lastSendBuffer release].

As far as I can see, there is no need to call release on _lastSendBuffer because it is owned by _sendBuffers and is released in [_sendBuffers release] call. But may be I'm wrong and the problem lies in something else.
User avatar
Lapo
Site Admin
Posts: 21116
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 14 May 2009, 08:04

New API available! -> viewtopic.php?t=5106
Lapo

--

gotoAndPlay()

...addicted to flash games
stager
Posts: 12
Joined: 06 May 2009, 11:28

Postby stager » 15 May 2009, 14:27

Lapo wrote:New API available! -> viewtopic.php?t=5106


Thanks!
Dest987
Posts: 12
Joined: 21 Apr 2009, 01:37

Postby Dest987 » 11 Jun 2009, 21:55

Dest987 wrote:In handleUserLeaveRoom you get the user name but then when you remove the user from the room right after that, it destroys the user name. Need to retain the user name until after you are done calling the callback function.


Looks like your fix for this creates a memory leak. You do a copy but never release that copy. (unless I'm misunderstanding what copy does, which could be true since I've never used it before.)
Dest987
Posts: 12
Joined: 21 Apr 2009, 01:37

Postby Dest987 » 12 Jun 2009, 01:12

There is also an error in leaveRoom. The %@ should be a %d since you're passing in an NSInteger. It crashes at runtime otherwise.
stager
Posts: 12
Joined: 06 May 2009, 11:28

Postby stager » 08 Jul 2009, 12:55

Hi!

It looks like "[doc release];" call is missing in INFSmartFoxExtHandler.m in
handleMessage:type:delegate: , which causes memory leak. "doc" is allocated at line 41 and there is no correspondent "release" call.

Good luck!

PS: the problem is in 1.0.0beta2

Return to “iPhone Objective-C API”

Who is online

Users browsing this forum: No registered users and 1 guest