Wowza Community

Textchat on Ios device

Hello,

I’m trying to implement a textchat client on IOS device.

I found the library Midnightcoder Comm Lib IOS which allow me to connect to the server and use shared object and invoke server side command.

I manage to connect to the server but i’m when i try to invoke the addmessage function from the server side. I think i might have a problems with the parameters of the function.

On my server the function is :

public void addMessage(IClient client, RequestFunction function, AMFDataList params)

My working flash client use the following method to invoke the function :

ncchat.call("addMessage", null, chatSharedObjectName, chatMessage)

My first problem is that i don’t understand the argument of my call function on my flash client. Where are the IClient client and RequestFunction function?

On my IOS client i tried this (the syntax is almost the same than the example given in the library except that they only use one argument :

NSString *method = @"addMessage";
NSMutableArray *args = [NSMutableArray array];
[args addObject:@"textchat"];
[args addObject:message];
[socket invoke:method withArgs:args];

Does anybody knows how the solve my invokation problem or how to implement the textchat on ios?

Best regards

Richard

Richard,

For Flash RTMP, the netconnection.call() is correctly formed and the server method’s signature is correct. That is how it works. Your chatSharedObjectName, chatMessage would be PARAM1 and PARAM2 server-side. You do not provide an argument for RequestFunction on the client-side.

I don’t have experience with the Midnightcoder module.

Richard

Richard,

It is:

netconnection.call("addMessage", Responder, data)

The Responder is a function that will handle the server-side response, e.g.:

sendResult(client, params, "Hello Wowza");

IClient is the server-side of the RTMP client NetConnection.

Richard

Thank you Richard for your answer.

So i understand that i don’t have to provide the RequestFunction parameters and i guess it is the same for the Iclient parameter?

Could you also tell me what is the null parameter in the flash function?

Best Regards

Richard

Richard,

Ok i solved my problem. In fact instead of creating a class based on NSObject in xcode to contain the message properties (time, user and message) you must use a NSDictionnary object or a NSMutableDictionnary. Here is a code sample for the send message function wich invokes the addmessage server function :

- (IBAction)SendMessage:(id)sender {
    NSMutableDictionary *chatMessage = [[NSMutableDictionary alloc]initWithCapacity:3];
    [chatMessage setValue:@"UserTest" forKey:@"user"];
    [chatMessage setValue:@"MessageTest" forKey:@"message"];
    [chatMessage setValue:[NSDate date] forKey:@"time"];
    
    NSString *method = @"addMessage";
    NSMutableArray *args = [NSMutableArray array];
    [args addObject:@"textchat"];
    [args addObject:chatMessage];
    [socket invoke:method withArgs:args responder:[AsynCall call:self method:@selector(onaddMessage:)]];
}

It is strange because it seems to work with a custom class but it create an instable behavior on the server side (it generates a bufferunderflow error wich sometimes freeze the server).

Thank you for your help. I hope this message will help other people working on IOS implementation of the textchat.

Best regards

Richard