Instant Messenger functionality using c#

Please post requests related to the sipsorcery library to the GitHub repo https://github.com/sipsorcery/sipsorcery/issues.
Locked
siva
Posts: 4
Joined: Sat Mar 04, 2017 10:31 am

Instant Messenger functionality using c#

Post by siva » Sat Mar 04, 2017 10:32 am

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

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: Instant Messenger functionality using c#

Post by Aaron » Tue Mar 07, 2017 10:10 am

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 https://www.ietf.org/rfc/rfc3428.txt.

siva
Posts: 4
Joined: Sat Mar 04, 2017 10:31 am

Re: Instant Messenger functionality using c#

Post by siva » Sun Mar 12, 2017 9:46 am

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..
m_sipTransport.SendRequest(sipMessageRequest);


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.

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: Instant Messenger functionality using c#

Post by Aaron » Sun Mar 19, 2017 10:26 am

I don't have any code for SIP instant messaging.

The closest example is probably sending a SIP NOTIFY request. Take a look at https://github.com/sipsorcery/sipsorcer ... 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.

Locked