iPhone Debugreturn

Cuze
edited December 2010 in Native
Hey,
we noticed that every response from the server sends a debug message to the client. I am wondering how i can read out this message on the iPhone and when debugreturn is called. Can anybody explain it to me?? This would be really nice.

Comments

  • Yes, you can read it out. Which language version of Photon are you using clientside? C, C++ or objC?
  • I am using ObjC. :)
  • I have a second question. I am trying to send a NSString to the server but I dont know how to convert the string that it is sendable. Here is my example for integer sending, but how can i send a NSString?
    NSMutableDictionary* ev = [[NSMutableDictionary alloc] init];
    	
    	
    	// nByte key and int value:
    	nByte POS_X = 100;
    	int x = 42;
    	KeyObject* keyObject = [[KeyObject alloc] initWithByteValue:POS_X];
    	NSValue* valueObject = [NSValue valueWithBytes:&x objCType:@encode(int)];
    	[ev setObject:valueObject forKey:keyObject];
    	[keyObject release];
    	
    	
    	NSLog(@"SENDE");	
    	[m_pLitePeer opCustom:10 :ev :NO];
    	[ev release];
    
  • Then you can route the complete operation response from the server in PhotonPeerReturn() to your debugging method like this:
    [self DebugReturn:DEBUG_LEVEL_INFO :[NSString stringWithFormat:@"PhotonPeerReturn: %d %d %@", opCode, returnCode, [Utils hashToString:returnValues :true]]];
    

    or only the debugmessage, if any (there is only one, if something went wrong, it isn't sent, if all works fine, for performance reasons):
    if(returnCode)
    	[self DebugReturn:DEBUG_LEVEL_ALL :[returnValues objectForKey:[KeyObject withByteValue:P_DBG]]];
    

    Your debug method could then be implemented for example somehow like this:
    - (void) DebugReturn:(PhotonPeer_DebugLevel)debugLevel :(NSString*)string
    {
    	switch(debugLevel)
    	{
    		case DEBUG_LEVEL_ERRORS:
    			DBGPRINTF_ERROR("debugReturn: %s", [string UTF8String]);
    			break;
    		case DEBUG_LEVEL_WARNINGS:
    			DBGPRINTF_WARNING("debugReturn: %s", [string UTF8String]);
    			break;
    		case DEBUG_LEVEL_INFO:
    			DBGPRINTF_INFO("debugReturn: %s", [string UTF8String]);
    			break;
    		case DEBUG_LEVEL_ALL:
    			DBGPRINTF_DEBUG("debugReturn: %s", [string UTF8String]);
    			break;
    		default:
    			DBGPRINTF_ERROR("ERROR: debugReturn - received unknown debug level");
    			break;
    	}
    }
    

    debug output of the client is automatically sent to your debugReturn, if you set the debug level accordingly:
    mLitePeer.DebugOutputLevel = DEBUG_LEVEL_ALL; // attention, all is a lot, you should not set this for distribution builds or at filter it in your DebugReturn again or not print it to the console, as printing much debug out to the console is really expensive on device
    mLitePeer = [[LitePeer alloc] init:listener]; listener has to implement the <PhotonListener> protocol
    


    To your second question:
    I modified you sample code for sending a string key key and a string value:
    // NSString* key and NSString* value:
       KeyObject* keyObject = [[KeyObject alloc] initWithStringValue:@"key"];
       NSString* myString = @"Hello Photon String Sending World!";
       [ev setObject:myString forKey:keyObject];
       [keyObject release];
       
       
       NSLog(@"SENDE");   
       [m_pLitePeer opCustom:10 :ev :NO];
       [ev release];
    
  • Thank you very much for your help!!!