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.
iPhone bugs
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.
Should probably check the rest of the functions to make sure you will never get a nil value that kills the following parameters.
- cemuzunlar
- Posts: 47
- Joined: 26 Dec 2008, 00:45
- Contact:
Re: iPhone bugs
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
Infosfer Game and Visualization Technologies
http://www.infosfer.com
contact@infosfer.com
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?
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?
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:
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).
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).
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.
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.
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.)
Return to “iPhone Objective-C API”
Who is online
Users browsing this forum: No registered users and 0 guests