Page 1 of 1

Instant Messenger functionality using c#

Posted: Sat Mar 04, 2017 10:32 am
by siva
I have followed your softphone example and managed to integrate and get call functionality work my c# application. I am in need of a sample code on how to Send Message using C# code. I can receive message but not able to send message. Not clear on code to use for sending message

Re: Instant Messenger functionality using c#

Posted: Tue Mar 07, 2017 10:10 am
by Aaron
Do you mean instant messaging via the SIP MESSAGE request?

If so it's a matter of sending the MESSAGE request to the destination user agent with the message in the body of the request. If the destination user agent supports it, your mileage may very here, then it will do something with the message otherwise you'll get back a Method Not Supported response or similar.

As always with SIP if you want the details go straight to the RFC

Re: Instant Messenger functionality using c#

Posted: Sun Mar 12, 2017 9:46 am
by siva
Thanks Aaron for your reply. Yes, Instant Messaging via SIP Message request. I am using asterisk server.

How to do the same with Sipsorcery? I am able to use CSipSimple Softphone and messaging work. Also, tried with independentsoft dll and able to message from that as well using C# code. But, couldn't find a sample code in Sipsorcery for me to use Messaging feature.

Do you have any method to be used in-built like below, where i will get a response when message is delivered? or how easy we can include the same?

SIPClientUserAgent.SendMessage(string fromURI, string toURI, string message);

I tried to probe more, but was not successful using SIPTransport. SendRequest or even not sure which SIPTransaction I can use.

//Sample code
SIPRequest sipMessageRequest = new SIPRequest(SIPMethodsEnum.MESSAGE, uri);
///Filled the SIPViaset, headers, etc..

I can use independentsoft for sending message. But registering two SIP client one with independentsoft and another with sipsorcery might not be the right way and my application need both IM and call functionality.

Re: Instant Messenger functionality using c#

Posted: Sun Mar 19, 2017 10:26 am
by Aaron
I don't have any code for SIP instant messaging.

The closest example is probably sending a SIP NOTIFY request. Take a look at ... Manager.cs line 310 and the SendNotifyRequestForSubscription method. That method sends a single NOTIFY request. If you change the method to MESSAGE and modify any headers you need it will get you pretty close.