Class MsrpConnection
Class for managing a single MSRP connection to either a remote server or from a remote client.
Inherited Members
Namespace: SipLib.Msrp
Assembly: SipLib.dll
Syntax
public class MsrpConnection
Properties
| Edit this page View SourceConnectionIsPassive
Returns true if the connection is passive, i.e., this end is the server and listening for connection requests. Returns false if this end of the connection is the client.
Declaration
public bool ConnectionIsPassive { get; }
Property Value
Type | Description |
---|---|
bool |
LocalMsrpUri
Gets the local MsrpUri for this connection or null if not set yet.
Declaration
public MsrpUri? LocalMsrpUri { get; }
Property Value
Type | Description |
---|---|
MsrpUri |
MaxMsrpMessageLength
Gets or sets the maximum size of a complete MSRP message that the MsrpConnection can receive.
The default size is 10,000 bytes. The minimum limit on the message length is 3,000 bytes. There is no upper limit. For text applications it is not necessary to change the default. If the application will be expected to receive large images or video files then this property must be set to an appropriate value.
This property must be set before calling the Start() method.
Declaration
public int MaxMsrpMessageLength { get; set; }
Property Value
Type | Description |
---|---|
int |
RemoteMsrpUri
Gets the remote MsrpUri for this connection or null if not set yet.
Declaration
public MsrpUri? RemoteMsrpUri { get; }
Property Value
Type | Description |
---|---|
MsrpUri |
Methods
| Edit this page View SourceCreateAsClient(MsrpUri, MsrpUri, X509Certificate2)
Creates a client MsrpConnection object. Call this method to create a client that connects to a remote endpoint that listens as a server. After calling this method, hook the events and then call the Start() method when ready to connect.
Declaration
public static MsrpConnection CreateAsClient(MsrpUri LocalMsrpUri, MsrpUri RemoteMsrpUri, X509Certificate2 LocalCert)
Parameters
Type | Name | Description |
---|---|---|
MsrpUri | LocalMsrpUri | MsrpUri of the local endpoint. The host portion of the URI must be a valid IPEndPoint object. |
MsrpUri | RemoteMsrpUri | MsrpUri of the remote endpoint to connect to. The host portion of the URI must be a valid IPEndPoint. |
X509Certificate2 | LocalCert | X.509 certificate to use for MSRP over TLS (MSRPS) for optional mutual authentication as a client. Optional. May be null is not using MSRP over TLS. |
Returns
Type | Description |
---|---|
MsrpConnection | Returns a new MsrpConnection object. |
CreateAsServer(MsrpUri, MsrpUri, X509Certificate2)
Creates a new MsrpConnection object that listens for MSRP connection requests as a server. After calling this method, hook the events and then call the Start() method.
Declaration
public static MsrpConnection CreateAsServer(MsrpUri LocalMsrpUri, MsrpUri RemoteMsrpUri, X509Certificate2 LocalCert)
Parameters
Type | Name | Description |
---|---|---|
MsrpUri | LocalMsrpUri | Specifies the MsrpUri that the server listens on. The host portion of the URI must be a valid IPEndPoint. |
MsrpUri | RemoteMsrpUri | Specifies the MsrpUri that the remote client will be connecting from. The host portion of the URI must be a valid IPEndPoint. |
X509Certificate2 | LocalCert | X.509 certificate to use. Required if using MSRP over TLS (MSRPS). May be null if using MSRP over TCP. |
Returns
Type | Description |
---|---|
MsrpConnection | Returns a new MsrpConnection object. |
CreateFromSdp(MediaDescription, MediaDescription, bool, X509Certificate2?)
Creates a MsrpConnection from the offered and answered SDP.
Declaration
public static (MsrpConnection?, string?) CreateFromSdp(MediaDescription OfferedMd, MediaDescription AnsweredMd, bool IsIncoming, X509Certificate2? LocalCert)
Parameters
Type | Name | Description |
---|---|---|
MediaDescription | OfferedMd | The offered MediaDescription for MSRP ("message") media |
MediaDescription | AnsweredMd | The answered MediaDescription for MSRP ("message") media |
bool | IsIncoming | If true then its an incoming call. Else its an outgoing call |
X509Certificate2 | LocalCert | X.509 certificate to use for MSRP over TLS (MSRPS) |
Returns
Type | Description |
---|---|
(MsrpConnection, string) | Returns a tuple containing a MsrpConnection object and a string. If the returned MsrpConnection object is null, then the will contain an error message explaining why the MsrpConnection could no be created. |
GetPathMsrpUri(MediaDescription)
Parses the path attribute of a MediaDescription and returns a MsrpUri object
Declaration
public static MsrpUri? GetPathMsrpUri(MediaDescription Md)
Parameters
Type | Name | Description |
---|---|---|
MediaDescription | Md | MediaDescription for MSRP media |
Returns
Type | Description |
---|---|
MsrpUri | Returns a new MsrpUri object or null if an error occurred |
SendMsrpMessage(string, byte[], string?)
Sends an MSRP message to the remote endpoint. The method queues the message for transmission and returns immediately. It does not block. If the length of the message contents is longer than 2048 bytes, then the message is split up into chunks and each message chunk is queued. To send an empty SEND request, set the ContentType and the Contents parameters to null.
Declaration
public void SendMsrpMessage(string ContentType, byte[] Contents, string? messageID = null)
Parameters
Type | Name | Description |
---|---|---|
string | ContentType | Specifies the Content-Type header value for the message. For example: text/plain or message/CPIM. |
byte[] | Contents | Binary message contents encoded using UTF8 if the message is text or the binary contents if sending a non-text message such as a picture or a video file. |
string | messageID | If specified, this is the Message-ID header that will be include in the SEND request. This should be a 9 or 10 character alphanumeric string that identifies the message. This parameter is optional. If present then the SEND request will include a Success-Report header with a value of "yes" so that the remote endpoint will generate a success report. |
Shutdown()
Call this method to close all network connections. This method must be called when a call ends or if the MSRP session must be ended in case of a re-INVITE request to change the media destination or characteristics.
Declaration
public void Shutdown()
Start()
Starts the connection process as a MSRP client or as a MSRP server depending upon the configuration.
Declaration
public void Start()
Events
| Edit this page View SourceMsrpConnectionEstablished
This event is fired when a connection is established with the remote endpoint either as a client or as a server.
Declaration
public event MsrpConnectionStatusDelegate? MsrpConnectionEstablished
Event Type
Type | Description |
---|---|
MsrpConnectionStatusDelegate |
MsrpConnectionFailed
This event is fired if the MsrpConnection object was unable to connect to the remote endpoint as a client.
Declaration
public event MsrpConnectionStatusDelegate? MsrpConnectionFailed
Event Type
Type | Description |
---|---|
MsrpConnectionStatusDelegate |
MsrpMessageDeliveryFailed
This event is fired if the remote endpoint rejected a MSRP message sent by the MsrpConnection object or if there was another problem delivering the message.
Declaration
public event MsrpMessageDeliveryFailedDelegate? MsrpMessageDeliveryFailed
Event Type
Type | Description |
---|---|
MsrpMessageDeliveryFailedDelegate |
MsrpMessageReceived
Event that is fired when a complete MSRP message is received. This event is not fired for empty SEND requests. Use this event if you wish to parse and process the complete MSRP message given the Content-Type that is a custom type -- for example a binary type such as image/jpeg.
If the application only needs to handle text messages then use the MsrpTextMessageReceived event.
Declaration
public event MsrpMessageReceivedDelegate? MsrpMessageReceived
Event Type
Type | Description |
---|---|
MsrpMessageReceivedDelegate |
MsrpMessageSent
Event that is fired when this MsrpConnection object sends a new MSRP message. The purpose of this event is for active SIP recording (SIPREC).
Declaration
public event MsrpMessageSentDelegate? MsrpMessageSent
Event Type
Type | Description |
---|---|
MsrpMessageSentDelegate |
MsrpTextMessageReceived
Event that fired when an MSRP message is received with a Content-Type of text/plain or message/cpim and the content type of the CPIM message is text/plain.
Declaration
public event MsrpTextMessageReceivedDelegate? MsrpTextMessageReceived
Event Type
Type | Description |
---|---|
MsrpTextMessageReceivedDelegate |
ReportReceived
Event that is fired when a MSRP REPORT request is received.
Declaration
public event ReportReceivedDelegate? ReportReceived
Event Type
Type | Description |
---|---|
ReportReceivedDelegate |