Show / Hide Table of Contents

Class SIPWebSocketChannel

A SIP transport Channel for transmitting SIP over a Web Socket communications layer as per RFC7118.

var sipTransport = new SIPTransport();
var wsSipChannel = new SIPWebSocketChannel(IPAddress.Loopback, 80);

var wssCertificate = new System.Security.Cryptography.X509Certificates.X509Certificate2("localhost.pfx");
var wssSipChannel = new SIPWebSocketChannel(IPAddress.Loopback, 433, wssCertificate);

sipTransport.AddSIPChannel(wsSipChannel);
sipTransport.AddSIPChannel(wssSipChannel);
Inheritance
System.Object
SIPChannel
SIPWebSocketChannel
Implements
System.IDisposable
Inherited Members
SIPChannel.logger
SIPChannel.ID
SIPChannel.LocalIPAddresses
SIPChannel.InternetDefaultAddress
SIPChannel.ListeningIPAddress
SIPChannel.Port
SIPChannel.ListeningEndPoint
SIPChannel.ListeningSIPEndPoint
SIPChannel.IsReliable
SIPChannel.IsSecure
SIPChannel.SIPProtocol
SIPChannel.Closed
SIPChannel.SIPMessageReceived
SIPChannel.SIPEncoding
SIPChannel.SIPBodyEncoding
SIPChannel.GetLocalIPAddressForDestination(IPAddress)
SIPChannel.GetContactURI(SIPSchemesEnum, SIPEndPoint)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: SIPSorcery.SIP
Assembly: SIPSorcery.dll
Syntax
public class SIPWebSocketChannel : SIPChannel, IDisposable

Constructors

| Improve this Doc View Source

SIPWebSocketChannel(IPAddress, Int32)

Declaration
public SIPWebSocketChannel(IPAddress listenAddress, int listenPort)
Parameters
Type Name Description
System.Net.IPAddress listenAddress
System.Int32 listenPort
| Improve this Doc View Source

SIPWebSocketChannel(IPAddress, Int32, X509Certificate2)

Creates a new secure web socket server (e.g. wss://localhost).

Declaration
public SIPWebSocketChannel(IPAddress listenAddress, int listenPort, X509Certificate2 certificate)
Parameters
Type Name Description
System.Net.IPAddress listenAddress

The IPv4 or IPv6 address to listen on.

System.Int32 listenPort

The network port to listen on.

System.Security.Cryptography.X509Certificates.X509Certificate2 certificate

The X509 certificate to supply to connecting clients. Unless the client has been specifically configured otherwise the it will perform validation on the certificate which typically involved checking that the hostname of the server matches the certificate's common name.

| Improve this Doc View Source

SIPWebSocketChannel(IPEndPoint, X509Certificate2)

Declaration
public SIPWebSocketChannel(IPEndPoint endPoint, X509Certificate2 certificate)
Parameters
Type Name Description
System.Net.IPEndPoint endPoint
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate
| Improve this Doc View Source

SIPWebSocketChannel(IPEndPoint, Encoding, Encoding, X509Certificate2)

Creates a SIP channel to listen for and send SIP messages over a web socket communications layer.

Declaration
public SIPWebSocketChannel(IPEndPoint endPoint, Encoding sipEncoding, Encoding sipBodyEncoding, X509Certificate2 certificate)
Parameters
Type Name Description
System.Net.IPEndPoint endPoint

The IP end point to listen on and send from.

System.Text.Encoding sipEncoding
System.Text.Encoding sipBodyEncoding
System.Security.Cryptography.X509Certificates.X509Certificate2 certificate

Fields

| Improve this Doc View Source

SIP_Sec_WebSocket_Protocol

Declaration
public const string SIP_Sec_WebSocket_Protocol = "sip"
Field Value
Type Description
System.String

Methods

| Improve this Doc View Source

Close()

Stops the web socket server and closes any client connections.

Declaration
public override void Close()
Overrides
SIPChannel.Close()
| Improve this Doc View Source

Dispose()

Calls close on the channel when it is disposed.

Declaration
public override void Dispose()
Overrides
SIPChannel.Dispose()
| Improve this Doc View Source

HasConnection(SIPEndPoint)

Checks whether there is an existing client web socket connection for a remote end point.

Declaration
public override bool HasConnection(SIPEndPoint remoteEndPoint)
Parameters
Type Name Description
SIPEndPoint remoteEndPoint

The remote end point to check for an existing connection.

Returns
Type Description
System.Boolean

True if there is a connection or false if not.

Overrides
SIPChannel.HasConnection(SIPEndPoint)
| Improve this Doc View Source

HasConnection(String)

Checks whether the web socket SIP channel has a connection matching a unique connection ID.

Declaration
public override bool HasConnection(string connectionID)
Parameters
Type Name Description
System.String connectionID

The connection ID to check for a match on.

Returns
Type Description
System.Boolean

True if a match is found or false if not.

Overrides
SIPChannel.HasConnection(String)
| Improve this Doc View Source

HasConnection(Uri)

Not implemented for the this channel.

Declaration
public override bool HasConnection(Uri serverUri)
Parameters
Type Name Description
System.Uri serverUri
Returns
Type Description
System.Boolean
Overrides
SIPChannel.HasConnection(Uri)
| Improve this Doc View Source

IsAddressFamilySupported(AddressFamily)

Checks whether the specified address family is supported.

Declaration
public override bool IsAddressFamilySupported(AddressFamily addresFamily)
Parameters
Type Name Description
System.Net.Sockets.AddressFamily addresFamily

The address family to check.

Returns
Type Description
System.Boolean

True if supported, false if not.

Overrides
SIPChannel.IsAddressFamilySupported(AddressFamily)
| Improve this Doc View Source

IsProtocolSupported(SIPProtocolsEnum)

Checks whether the specified protocol is supported.

Declaration
public override bool IsProtocolSupported(SIPProtocolsEnum protocol)
Parameters
Type Name Description
SIPProtocolsEnum protocol

The protocol to check.

Returns
Type Description
System.Boolean

True if supported, false if not.

Overrides
SIPChannel.IsProtocolSupported(SIPProtocolsEnum)
| Improve this Doc View Source

SendAsync(SIPEndPoint, Byte[], Boolean, String)

Ideally sends on the web socket channel should specify the connection ID. But if there's a good reason not to we can check if there is an existing client connection with the requested remote end point and use it.

Declaration
public override async Task<SocketError> SendAsync(SIPEndPoint destinationEndPoint, byte[] buffer, bool canInitiateConnection, string connectionIDHint)
Parameters
Type Name Description
SIPEndPoint destinationEndPoint

The remote destination end point to send the data to.

System.Byte[] buffer

The data to send.

System.Boolean canInitiateConnection
System.String connectionIDHint

The ID of the specific web socket connection to try and send the message on.

Returns
Type Description
System.Threading.Tasks.Task<System.Net.Sockets.SocketError>

If no errors SocketError.Success otherwise an error value.

Overrides
SIPChannel.SendAsync(SIPEndPoint, Byte[], Boolean, String)
| Improve this Doc View Source

SendSecureAsync(SIPEndPoint, Byte[], String, Boolean, String)

Not implemented for the WebSocket channel.

Declaration
public override Task<SocketError> SendSecureAsync(SIPEndPoint dstEndPoint, byte[] buffer, string serverCertificateName, bool canInitiateConnection, string connectionIDHint)
Parameters
Type Name Description
SIPEndPoint dstEndPoint
System.Byte[] buffer
System.String serverCertificateName
System.Boolean canInitiateConnection
System.String connectionIDHint
Returns
Type Description
System.Threading.Tasks.Task<System.Net.Sockets.SocketError>
Overrides
SIPChannel.SendSecureAsync(SIPEndPoint, Byte[], String, Boolean, String)

Implements

System.IDisposable

Extension Methods

JSONWriter.ToJson(Object)
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX