# Textchat on Ios device

**URL:** <https://community.wowza.com/t/textchat-on-ios-device/39992>\
**Category:** Wowza Developer Dojo\
**Tags:** wowza-streaming-server-java-api\
**Created:** [February 6, 2014, 6:49am UTC](https://community.wowza.com/t/textchat-on-ios-device/39992 "2014-02-06T06:49:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Richard\_Perez](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@Richard\_Perez](https://community.wowza.com/u/Richard_Perez)\
**Post date:** [February 6, 2014, 6:49am UTC](https://community.wowza.com/t/textchat-on-ios-device/39992/1 "2014-02-06T06:49:01Z")

</div>

Hello,

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

I found the library [Midnightcoder Comm Lib IOS](http://blog.themidnightcoders.com/index.php/2011/07/07/ios-applications-wowza-media-server-integration-with-rtmp/) 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 :

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

```

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

```auto
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 :

```auto
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

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [February 6, 2014, 3:11pm UTC](https://community.wowza.com/t/textchat-on-ios-device/39992/2 "2014-02-06T15:11:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [February 7, 2014, 6:23pm UTC](https://community.wowza.com/t/textchat-on-ios-device/39992/3 "2014-02-07T18:23:19Z")

</div>

Richard,

It is:

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

```

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

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

```

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

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Perez](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@Richard\_Perez](https://community.wowza.com/u/Richard_Perez)\
**Post date:** [February 6, 2014, 8:12am UTC](https://community.wowza.com/t/textchat-on-ios-device/39992/4 "2014-02-06T08:12:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Richard\_Perez](https://avatars.discourse-cdn.com/v4/letter/r/48db29/32.png) [@Richard\_Perez](https://community.wowza.com/u/Richard_Perez)\
**Post date:** [February 7, 2014, 1:52pm UTC](https://community.wowza.com/t/textchat-on-ios-device/39992/5 "2014-02-07T13:52:55Z")

</div>

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 :

```auto
- (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
