4 Copyright (C) 2010 Belledonne Communications SARL
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * @defgroup chatroom_tuto Chat room and messaging
24 *This program is a _very_ simple usage example of liblinphone,
25 *desmonstrating how to send/receive SIP MESSAGE from a sip uri identity passed from the command line.
26 *<br>Argument must be like sip:jehan@sip.linphone.org .
28 *ex chatroom sip:jehan@sip.linphone.org
36 #include "linphonecore.h"
38 #include "linphone/linphonecore.h"
43 static bool_t running=TRUE;
45 static void stop(int signum){
48 void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
49 printf(" Message [%s] received from [%s] \n",message,linphone_address_as_string (from));
54 int main(int argc, char *argv[]){
55 LinphoneCoreVTable vtable={0};
57 char* dest_friend=NULL;
60 /* takes sip uri identity from the command line arguments */
68 linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/
71 Fill the LinphoneCoreVTable with application callbacks.
72 All are optional. Here we only use the text_received callback
73 in order to get notifications about incoming message.
75 vtable.text_received=text_received;
78 Instantiate a LinphoneCore object given the LinphoneCoreVTable
80 lc=linphone_core_new(&vtable,NULL,NULL,NULL);
83 /*Next step is to create a chat root*/
84 LinphoneChatRoom* chat_room = linphone_core_create_chat_room(lc,dest_friend);
86 linphone_chat_room_send_message(chat_room,"Hello world"); /*sending message*/
88 /* main loop for receiving incoming messages and doing background linphone core work: */
90 linphone_core_iterate(lc);
94 printf("Shutting down...\n");
95 linphone_chat_room_destroy(chat_room);
96 linphone_core_destroy(lc);