send Instant text messages using SIPML5

1,205 views
Skip to first unread message

Sunil Chandrasekharan

unread,
Nov 9, 2012, 3:47:16 AM11/9/12
to doub...@googlegroups.com
Hello all,

is there any information available on how i can send instant messages between two connected users on sipml5 client.

Mamadou

unread,
Nov 9, 2012, 10:43:39 AM11/9/12
to doub...@googlegroups.com, Sunil Chandrasekharan
var oSessionIM = new tsip_session_message(oSipStack,
tsip_session.prototype.SetToStr("2233422677"), // the destination number
tsip_session.prototype.SetHeader("What", "IM") // not required
);
// listen for messaging events
oSipStack.on_event_message = function (evt) {
console.debug(evt.s_phrase);
switch (evt.e_message_type) {
case tsip_event_message_type_e.I_MESSAGE: // Incoming message
{
evt.get_session().accept(); // send SIP 200 OK
console.debug("Incoming message=%s", evt.get_message().get_content_as_string());
break;
}
case tsip_event_message_type_e.AO_MESSAGE: // Answer to Outgoing message
{
if (evt.i_code >= 200 && evt.i_code <= 299) {
console.debug("sent");
}
else if (evt.i_code >= 300) {
console.debug("not sent (%d)", evt.i_code);
}
break;
}
}
};
// send the Instant Message (SIP MESSAGE request)
oSessionIM.send(
new String("P�che � la moule"), // content
"text/plain; charset=utf8" // content type
);
> --
>
>

Message has been deleted

Mamadou

unread,
Nov 19, 2012, 12:59:06 PM11/19/12
to doub...@googlegroups.com, Sunil Chandrasekharan
anywhere in your app.

On 11/19/2012 10:16 AM, Sunil Chandrasekharan wrote:
Hi Thanks Mamadou,

this code snippet is already available?
or do i have to add this snippet somehwere?

Please tell me how and where to add this code snippet to enable a text filed for sending messages.


On Friday, November 9, 2012 9:13:51 PM UTC+5:30, Mamadou wrote:
var oSessionIM = new tsip_session_message(oSipStack,
        tsip_session.prototype.SetToStr("2233422677"), // the destination number
        tsip_session.prototype.SetHeader("What", "IM") // not required
);
// listen for messaging events
oSipStack.on_event_message = function (evt) {
        console.debug(evt.s_phrase);
        switch (evt.e_message_type) {
                case tsip_event_message_type_e.I_MESSAGE: // Incoming message
                        {
                                evt.get_session().accept(); // send SIP 200 OK
                                console.debug("Incoming message=%s", evt.get_message().get_content_as_string());
                                break;
                        }
                case tsip_event_message_type_e.AO_MESSAGE: // Answer to Outgoing message
                        {
                                if (evt.i_code >= 200 && evt.i_code <= 299) {
                                        console.debug("sent");
                                }
                                else if (evt.i_code >= 300) {
                                        console.debug("not sent (%d)", evt.i_code);
                                }
                                break;
                        }
        }
};
// send the Instant Message (SIP MESSAGE request)
oSessionIM.send(
        new String("P�che � la moule"), // content
        "text/plain; charset=utf8" // content type
);
 



On 11/9/2012 9:47 AM, Sunil Chandrasekharan wrote:
> Hello all,
>
> is there any information available on how i can send instant messages
> between two connected users on sipml5 client.
>
> --
>
>

--
 
 

Sunil Chandrasekharan

unread,
Nov 20, 2012, 6:26:25 AM11/20/12
to doub...@googlegroups.com, Sunil Chandrasekharan
Hi Mamadou,

Thanks for the information.
I am actually asking about using SIPML5 client source code / IMSDroid source code.
Based on these context, where should i add this code snippet..

Inside SIPML5 and IMSDroid code, where should i add ..i mean which file i need to edit

Sunil Chandrasekharan

unread,
Nov 21, 2012, 3:53:48 AM11/21/12
to doub...@googlegroups.com, Sunil Chandrasekharan
Hi All,

Kindly let me know how to edit the sipml5 client code locally to enable sending text message during video call between two users.
As Mamdou shared a sinppet of code, where should i add this code inside the sipml5 source code.

Hadi Ams

unread,
Nov 21, 2012, 4:34:16 AM11/21/12
to doub...@googlegroups.com, Sunil Chandrasekharan
Hi,
I think you can directly use it inside call.htm .
Create some functions that will be called when you want to send a text message or waiting for messages.
You should create a section on the page to send and receive text messages.
Have a look at the source , this text message code is very similar to "call" or "register" functions.
I think if you try to understand the general syntax of how to use the  sipml5 java script sources and functions in call.htm , the rest should be easy :)

PURUSHOTTAM MISHRA

unread,
Aug 26, 2013, 6:08:56 AM8/26/13
to doub...@googlegroups.com, Sunil Chandrasekharan
Hi Manmadou,
           Thanks for sharing the code for IM.
           I have used your code in call.htm page.
          Perhaps I have done some mistake because its not working at all.
         What I have done is:
        1.Made a function which will be called on clicking a button ;;
              function sipIM()

{
alert("hello");
var oSessionIM = new tsip_session_message(oSipStack, 
        tsip_session.prototype.SetToStr("sip:ka...@tcs.com"), // the destination number 
        tsip_session.prototype.SetHeader("What", "IM") // not required 
);
alert("hi");
oSessionIM.send( new String("hello"),"text/plain; charset=utf8"); 


}


And the rest part of code I have pasted inside this block:::
    // Callback function for SIP sessions (INVITE, REGISTER, MESSAGE...)
    function onSipEventSession(e /* SIPml.Session.Event */).


Bur its not working.
Regards
Purushottam

Mamadou DIOP

unread,
Aug 26, 2013, 12:13:02 PM8/26/13
to doub...@googlegroups.com, Sunil Chandrasekharan
You're using deprecated/private code.
The right way to send messages is explained at http://sipml5.org/docgen/index.html?svn=200#sendMessage

--
You received this message because you are subscribed to the Google Groups "discuss-doubango" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doubango+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

PURUSHOTTAM MISHRA

unread,
Aug 27, 2013, 5:32:41 AM8/27/13
to doub...@googlegroups.com, Sunil Chandrasekharan


Hi Mamadou,
                 Thanks for reply.
                I referred the link that you have mentioned and used the same .
                I am using version 213 of sipml5 call.htm.
               I made a function and pasted the code that you have mentioned which will be called on clicking a button.
               Now where I have stucked is the function is getting called on clicking the button but the control is not traversing through out the function.
              Still I am there only where I was earlier.

              This is the function that I have inserted inside the call.htm


         function sipIM()
{
alert("inside sipim");
alert("inside sipim2222");
            var eventsListener = function(e){
alert("inside sipim3333333");
                console.info('session event = ' + e.type);
            }
            var sendMessage = function(){
alert("session event is inside send message");
                messageSession = oSipStack.newSession('message', {
                    events_listener: { events: '*', listener: eventsListener } // optional: '*' means all events
                });
                messageSession.send('sip:b...@officesip.local', 'Pêche à la moule', 'text/plain;charset=utf-8');
            }

var acceptMessage = function(e){
                e.newSession.accept(); // e.newSession.reject(); to reject the message
                console.info('SMS-content = ' + e.getContentString() + ' and SMS-content-type = ' + e.getContentType());
            }
        

}

Thanks and Regards
Purushottam.

PURUSHOTTAM MISHRA

unread,
Aug 27, 2013, 7:36:56 AM8/27/13
to doub...@googlegroups.com, Sunil Chandrasekharan
Hi Mamdou,
                Thanks for your reply.
                I have tried the link that you have provided.
               Again I made a function in call.htm page.
              I have added that much code which is given at the site that you have provided.

              On clicking the button the function sipIM() is getting called but the control is coming out after prompting the second alert in the sipIM() function.

             
              Do I have to add something for handling the SIP stack events for message.
              I have attached the call.htm page in which I have added a function named sipIM().
              If you could help me then it will be very beneficial.
            PFA.
    Thanks and Regards,
    Purushottam Mishra.
call.htm

Mamadou DIOP

unread,
Aug 27, 2013, 12:40:24 PM8/27/13
to doub...@googlegroups.com, Sunil Chandrasekharan
You cannot just copy/paste code without trying to understand what's supposed to do.
What you're doing here doesn't make sense. "sendMessage" is a variable referencing a function used to send a message. You're just declaring this variable and not calling it.
You should take time to read and understand the API.

PURUSHOTTAM MISHRA

unread,
Aug 28, 2013, 3:31:02 PM8/28/13
to doub...@googlegroups.com, Sunil Chandrasekharan
Hi Mamdou
           Thanks for your suggestion.
            I studied the api of sipml5 and now I am able to send and receive message.

Thanks and Regards
Purushottam Mishra.

Gopalakrishnan N

unread,
Mar 14, 2015, 7:54:00 AM3/14/15
to doub...@googlegroups.com, sunil....@gmail.com
Hi,

Can you please share some inputs, I tried the same script which you have given, but didn't worked for me. I see two alert message, since am new to Javascript, not able to get through it. 

Thanks. 

navaismo

unread,
Mar 14, 2015, 2:52:51 PM3/14/15
to doub...@googlegroups.com, sunil....@gmail.com
As a suggestion: then start learning javascript because the code for send and receive message is preety clear but you need the js background to handle it.

Gopalakrishnan N

unread,
Mar 16, 2015, 8:50:09 AM3/16/15
to doub...@googlegroups.com, sunil....@gmail.com
Ok thanks, let me go as suggested. 

But, actually how about the flow, where will I type the message, will I have to create a text box in call.htm file? Just to understand the flow... 

Thanks. 

Gopalakrishnan N

unread,
Mar 16, 2015, 11:02:49 AM3/16/15
to doub...@googlegroups.com, sunil....@gmail.com
Moreover, I get this type of message in chrome browser when I login with a username,

Not implemented SIPml-api.js?svn=224:1 tsk_utils_log_error
SIPml-api.js?svn=224:3 tsip_dialog_layer.handle_incoming_message
SIPml-api.js?svn=224:3 tsip_transport_layer.handle_incoming_message
SIPml-api.js?svn=224:3 __tsip_transport_ws_onmessage

Will this affect the messaging part?

Thanks. 

Mamadou

unread,
Mar 16, 2015, 11:05:07 AM3/16/15
to doub...@googlegroups.com, sunil....@gmail.com


On Monday, March 16, 2015 at 1:50:09 PM UTC+1, Gopalakrishnan N wrote:
Ok thanks, let me go as suggested. 

But, actually how about the flow, where will I type the message, will I have to create a text box in call.htm file? Just to understand the flow... 
You're asking people to help you learn JavaScript. For sure you're not at the right place. 

Gopalakrishnan N

unread,
Mar 17, 2015, 5:22:46 AM3/17/15
to doub...@googlegroups.com, sunil....@gmail.com
The reason I asked is, just wanted to understand the SMS flow in WebRTC html page.... Based on that I Will study on the javascript side... Anyways thanks for the comments. 

navaismo

unread,
Mar 17, 2015, 4:41:12 PM3/17/15
to doub...@googlegroups.com, sunil....@gmail.com
Reply all
Reply to author
Forward
0 new messages