# Chat room and Messaging

## Typedefs
typedef struct _LinphoneChatRoom | LinphoneChatRoom
## Functions
LinphoneChatRoom * | linphone_core_create_chat_room (LinphoneCore *lc, const char *to)
void | linphone_chat_room_destroy (LinphoneChatRoom *cr)
const LinphoneAddress * | linphone_chat_room_get_peer_address (LinphoneChatRoom *cr)
void | linphone_chat_room_send_message (LinphoneChatRoom *cr, const char *msg)

## Detailed Description

Exchanging text messages
Messages are sent using LinphoneChatRoom object. First step is to create a chat room from a peer sip uri.

    LinphoneChatRoom* chat_room = linphone_core_create_chat_room(lc,"sip:joe@sip.linphone.org");

Once created, messages are sent using function linphone_chat_room_send_message() .

    linphone_chat_room_send_message(chat_room,"Hello world"); /*sending message*/

Incoming message are received from call back LinphoneCoreVTable.text_received

    void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
            printf(" Message [%s] received from [%s] \n",message,linphone_address_as_string (from));
    }

A complete tutorial can be found at : Chat room tutorial

## Typedef Documentation

typedef struct _LinphoneChatRoom LinphoneChatRoom

A chat room is the place where text messages are exchanged.
Can be created by linphone_core_create_chat_room().

## Function Documentation

LinphoneChatRoom* linphone_core_create_chat_room | ( | LinphoneCore * | lc,
|  | const char * | to |
| ) |  |  |

Create a new chat room for messaging from a sip uri like sip:joe@sip.linphone.org

Parameters:

  | lc | LinphoneCore object
  | to | destination address for messages

Returns:
  LinphoneChatRoom where messaging can take place.

void linphone_chat_room_destroy | ( | LinphoneChatRoom * | cr | ) |

Destructor

Parameters:

  | cr | LinphoneChatRoom object

const LinphoneAddress* linphone_chat_room_get_peer_address | ( | LinphoneChatRoom * | cr | ) |

get peer address associated to this LinphoneChatRoom

Parameters:

  | cr | LinphoneChatRoom object

Returns:
  LinphoneAddress peer address

void linphone_chat_room_send_message | ( | LinphoneChatRoom * | cr,
|  | const char * | msg |
| ) |  |  |

send a message to peer member of this chat room.

Parameters:

  | cr | LinphoneChatRoom object
  | msg | message to be sent