SIP .NET Class Library
SIP .NET Class Library
SIP .NET
Independentsoft.Sip
SipClient Class
SipClient Constructor
SipClient Properties
SipClient Methods
SipClient Events

# SipClient Class

SipClient is master class responsible for sending and receiving SIP messages.
Inheritance Hierarchy
System
Object
Independentsoft.Sip
SipClient

Namespace: Independentsoft.Sip
Assembly: Independentsoft.Sip (in Independentsoft.Sip.dll) Version: 1.0.700.17927
Syntax
C#
VB
Copy

    public class SipClient

    Public Class SipClient

The SipClient type exposes the following members.

Constructors

| Name | Description
--- | --- | ---
| SipClient | Initializes a new instance of the SipClient class.
| SipClient(String) | Initializes a new instance of the SipClient class using the specified domain.
| SipClient(String, ProtocolType) | Initializes a new instance of the SipClient class using the specified domain and protocol type.
| SipClient(String, Int32) | Initializes a new instance of the SipClient class using the specified domain and port number of SIP server.
| SipClient(String, Int32, ProtocolType) | Initializes a new instance of the SipClient class using the specified domain, port number and protocol type.
| SipClient(String, String, String) | Initializes a new instance of the SipClient class using the specified domain, username and password.
| SipClient(String, ProtocolType, String, String) | Initializes a new instance of the SipClient class using the specified domain, protocol type, username and password.
| SipClient(String, Int32, String, String) | Initializes a new instance of the SipClient class using the specified domain, port number, username and password.
| SipClient(String, Int32, ProtocolType, String, String) | Initializes a new instance of the SipClient class using the specified domain, port number, protocol type, username and password.

Top
Properties

| Name | Description
--- | --- | ---
| Accept | Gets or sets Accept header field. The Accept header field is used to indicate acceptable message Internet media types in the request body. The header field describes media types using the format type/sub-type commonly used in the Internet. If not present, the assumed acceptable request body format is application/sdp. The wildcard "*" can be used to specify all subtypes.
| Allow | Gets or sets Allow header field. The Allow header field lists the set of methods supported by the client.
| AuthenticationUsername | Gets or sets authentication user name. If is set then value of this property will be used instead of Username during authentication.
| Contact | Gets or sets Contact header field. The Contact header field is used to convey a URI that identifies the request/response originator.
| Dialogs | Gets array of existing dialogs.
| Domain | Gets or sets domain, name of IP address of the remote SIP server.
| LocalIPEndPoint | Gets or sets local IP address and the port number.
| Logger | Gets or sets logger.
| MaxForwards | Gets or sets Max-Forwards default header value for all requests.
| MaxRetryCount | Gets or sets number of attempts during wrong authentication.
| NatAddress | Gets or sets name or IP address of NAT device (for example router).
| Password | Gets or sets password.
| Port | Gets or sets port number of remote SIP server.
| Protocol | Gets or sets the protocol type of the client.
| RemoteIPEndPoint | Gets or sets remote IP address and the port number.
| Rport | Gets or sets remote port parameter in the Via header value for all requests. Default value is -1.
| TcpListenerSocket | Gets or sets tcp listener socket.
| TcpPermanentSocket | Gets or sets tcp permanent socket.
| TcpRequestSocket | Gets or sets tcp request socket.
| Timeout | The number of milliseconds to wait before the request times out. The default is 60000 milliseconds (60 seconds).
| UdpSocket | Gets or sets udp socket.
| UsePermanentTcpConnection | Gets or sets tcp connnection as permanent.
| UserAgent | Gets or sets user agent.
| Username | Gets or sets user name.

Top
Methods

| Name | Description
--- | --- | ---
| AcceptRequest(Request) | Sends "OK" response with status code 200.
| AcceptRequest(Request, String) | Sends "OK" response with status code 200 and the specified description text.
| Ack(Dialog) | Acknowledges final response of INVITE request.
| Ack(RequestResponse) | Acknowledges final response of INVITE request.
| Ack(Response) | Acknowledges final response of INVITE request.
| Ack(Dialog, SessionDescription) | Acknowledges final response of INVITE request.
| Ack(RequestResponse, SessionDescription) | Acknowledges final response of INVITE request.
| Ack(Response, SessionDescription) | Acknowledges final response of INVITE request.
| Authentication | Authentications the specified request.
| Bind | Associates a client with a local endpoint.
| Bind(IPEndPoint) | Associates a client with a local endpoint.
| Bye(Dialog) | Terminates established media session specified with the dialog.
| Bye(RequestResponse) | Terminates established media session specified with the requestResponse parameter.
| Bye(Response) | Terminates established media session specified with the response parameter.
| Cancel | Cancels last pending INVITE attempt.
| Cancel(Dialog) | Cancels pending INVITE attempt specified with the early dialog.
| ClearDialog | Clears the dialog.
| ClearDialogs | Clears the dialogs.
| ClearOldResponses | Clears the old responses.
| Connect | Establishes a connection to a remote host.
| Disconnect | Closes the connection and clean up any resources being used.
| Equals | (Inherited from Object.)
| Finalize | (Inherited from Object.)
| GetDialog(RequestResponse) | Gets existing dialog based on the specified RequestResponse.
| GetDialog(Response) | Gets existing dialog based on the specified response.
| GetHashCode | (Inherited from Object.)
| GetOptions(String, String) | Gets capabilities of a client or server.
| GetOptions(ContactInfo, ContactInfo) | Gets capabilities of a client or server.
| GetOptions(String, String, String) | Gets capabilities of a client or server.
| GetOptions(ContactInfo, ContactInfo, Contact) | Gets capabilities of a client or server.
| GetRegisteredContacts | Returns array of all existing registered contacts.
| GetType | (Inherited from Object.)
| Invite(Dialog, SessionDescription) | Changes characteristics of the existing session.
| Invite(Dialog, String, String) | Changes characteristics of the existing session.
| Invite(String, String, String, SessionDescription) | Invites another client to media session.
| Invite(ContactInfo, ContactInfo, Contact, SessionDescription) | Invites another client to media session.
| Invite(String, String, String, String, String) | Invites another client to media session.
| Invite(ContactInfo, ContactInfo, Contact, String, String) | Invites another client to media session.
| MemberwiseClone | (Inherited from Object.)
| ModifyEventState(String, String, String, Int32, PresenceDescription) | Updates existing event state.
| ModifyEventState(ContactInfo, String, String, Int32, PresenceDescription) | Updates existing event state.
| ModifyEventState(String, String, String, Int32, String, String) | Updates existing event state.
| ModifyEventState(ContactInfo, String, String, Int32, String, String) | Updates existing event state.
| Notify(Dialog, String) | Sends notification when particular event occurs.
| Notify(Dialog, String, String, String) | Sends notification when particular event occurs.
| Prack | Acknowledges receipt of reliably transported provisional response. Provisional responses is response with status code 1xx.
| PublishEventState(String, String, Int32, PresenceDescription) | Publishes initial event state.
| PublishEventState(ContactInfo, String, Int32, PresenceDescription) | Publishes initial event state.
| PublishEventState(String, String, Int32, String, String) | Publishes initial event state.
| PublishEventState(ContactInfo, String, Int32, String, String) | Publishes initial event state.
| Refer(Dialog, String) | Transfers call to resource specified with the referTo parameter.
| Refer(Dialog, String, String) | Transfers call to resource specified with the referTo parameter.
| Refer(String, String, String, String) | Transfers call to resource specified with the referTo parameter.
| Refer(ContactInfo, ContactInfo, Contact, String) | Transfers call to resource specified with the referTo parameter.
| Refer(String, String, String, String, String) | Transfers call to resource specified with the referTo parameter.
| Refer(ContactInfo, ContactInfo, Contact, String, String) | Transfers call to resource specified with the referTo parameter.
| RefreshEventState(String, String, String, Int32) | Refreshes previously established publications.
| RefreshEventState(ContactInfo, String, String, Int32) | Refreshes previously established publications.
| RefreshSubscription | Refreshes existing subscription with new expiration time.
| Register(String, ContactInfo) | Registers user to a SIP server. The user informs server of his current contact addresss.
| Register(String, String) | Registers user to a SIP server. The user informs server of his current contact addresss.
| Register(String, ContactInfo, Contact) | Registers user to a SIP server. The user informs server of his current contact addresss.
| Register(String, String, String) | Registers user to a SIP server. The user informs server of his current contact addresss.
| Reinvite(Dialog, SessionDescription) | Changes characteristics of the existing session.
| Reinvite(Dialog, String, String) | Changes characteristics of the existing session.
| RejectRequest(Request) | Sends "Decline" response with status code 603.
| RejectRequest(Request, String) | Sends "Decline" response with status code 603 and the specified description text.
| RemoveEventState(String, String, String) | Removes event state established by a prior publication.
| RemoveEventState(ContactInfo, String, String) | Removes event state established by a prior publication.
| SendAsynchRequest | Sends request to a client or server and does not wait for the response.
| SendInfo | Sends call signaling information to another client with which it has an established media session.
| SendMessage(Dialog, String) | Sends instant message. The content type of the message is "text/plain".
| SendMessage(String, String, String) | Sends instant message. The content type of the message is "text/plain".
| SendMessage(ContactInfo, ContactInfo, String) | Sends plain text instant message. The content type of the message is "text/plain".
| SendMessage(Dialog, String, String) | Sends instant message with the specified content type.
| SendMessage(String, String, String, String) | Sends instant message with the specified content type.
| SendMessage(ContactInfo, ContactInfo, String, String) | Sends instant message with the specified content type.
| SendRequest | Sends request to a client or server.
| SendResponse(Response) | Sends response to a client or server.
| SendResponse(Response, Request) | Sends response to a client or server.
| SendResponseAccepted(Request) | Sends "Accepted" response with status code 202.
| SendResponseAccepted(Request, String) | Sends "Accepted" response with status code 202 and the specified description text.
| SendResponseBadEvent(Request) | Sends "Bad Event" response with status code 489.
| SendResponseBadEvent(Request, String) | Sends "Bad Event" response with status code 489 and the specified description text.
| SendResponseBadExtension(Request) | Sends "Bad Extension" response with status code 420.
| SendResponseBadExtension(Request, String) | Sends "Bad Extension" response with status code 420 and the specified description text.
| SendResponseBadRequest(Request) | Sends "Bad Request" response with status code 400.
| SendResponseBadRequest(Request, String) | Sends "Bad Request" response with status code 400 and the specified description text.
| SendResponseBusyHere(Request) | Sends "Busy Here" response with status code 486.
| SendResponseBusyHere(Request, String) | Sends "Busy Here" response with status code 486 and the specified description text.
| SendResponseCallIsBeingForwarded(Request) | Sends "Call Is Being Forwarded" response with status code 181.
| SendResponseCallIsBeingForwarded(Request, String) | Sends "Call Is Being Forwarded" response with status code 181 and the specified description text.
| SendResponseCallQueued(Request) | Sends "Call Queued" response with status code 182.
| SendResponseCallQueued(Request, String) | Sends "Call Queued" response with status code 182 and the specified description text.
| SendResponseDecline(Request) | Sends "Decline" response with status code 603. It is same method as RejectRequest(Request).
| SendResponseDecline(Request, String) | Sends "Decline" response with status code 603 and the specified description text. It is same method as RejectRequest(Request).
| SendResponseForbidden(Request) | Sends "Forbidden" response with status code 403.
| SendResponseForbidden(Request, String) | Sends "Forbidden" response with status code 403 and the specified description text.
| SendResponseMethodNotAllowed(Request) | Sends "Method Not Allowed" response with status code 405.
| SendResponseMethodNotAllowed(Request, String) | Sends "Method Not Allowed" response with status code 405 and the specified description text.
| SendResponseNotAcceptable(Request) | Sends "Not Acceptable" response with status code 606.
| SendResponseNotAcceptable(Request, String) | Sends "Not Acceptable" response with status code 606 and the specified description text.
| SendResponseNotAcceptableHere(Request) | Sends "Not Acceptable Here" response with status code 488.
| SendResponseNotAcceptableHere(Request, String) | Sends "Not Acceptable Here" response with status code 488 and the specified description text.
| SendResponseOK(Request) | Sends "OK" response with status code 200. It is same method as AcceptRequest(Request).
| SendResponseOK(Request, String) | Sends "OK" response with status code 200 and the specified description text. It is same method as AcceptRequest(Request).
| SendResponseRequestPending(Request) | Sends "Request Pending" response with status code 491.
| SendResponseRequestPending(Request, String) | Sends "Request Pending" response with status code 491 and the specified description text.
| SendResponseRequestTerminated(Request) | Sends "Request Terminated" response with status code 487.
| SendResponseRequestTerminated(Request, String) | Sends "Request Terminated" response with status code 487 and the specified description text.
| SendResponseRinging(Request) | Sends "Ringing" response with status code 180.
| SendResponseRinging(Request, String) | Sends "Ringing" response with status code 180 and the specified description text.
| SendResponseSessionProgress(Request) | Sends "Session Progress" response with status code 183.
| SendResponseSessionProgress(Request, String) | Sends "Session Progress" response with status code 183 and the specified description text.
| SendResponseTrying(Request) | Sends "Trying" response with status code 100.
| SendResponseTrying(Request, String) | Sends "Trying" response with status code 100 and the specified description text.
| SendResponseUnauthorized(Request) | Sends "Unauthorized" response with status code 401.
| SendResponseUnauthorized(Request, String) | Sends "Unauthorized" response with status code 401 and the specified description text.
| SendResponseUnsupportedMediaType(Request) | Sends "Unsupported Media Type" response with status code 415.
| SendResponseUnsupportedMediaType(Request, String) | Sends "Unsupported Media Type" response with status code 415 and the specified description text.
| SendResponseUnsupportedURIScheme(Request) | Sends "Unsupported URI Scheme" response with status code 416.
| SendResponseUnsupportedURIScheme(Request, String) | Sends "Unsupported URI Scheme" response with status code 416 and the specified description text.
| Subscribe(String, String, String, Int32) | Subscribes in order to receiving notifications about a particular event specified with the event name.
| Subscribe(ContactInfo, ContactInfo, String, Int32) | Subscribes in order to receiving notifications about a particular event specified with the event name.
| Subscribe(String, String, String, String, Int32) | Subscribes in order to receiving notifications about a particular event specified with the event name.
| Subscribe(ContactInfo, ContactInfo, Contact, String, Int32) | Subscribes in order to receiving notifications about a particular event specified with the event name.
| Subscribe(String, String, String, String, String, Int32) | Subscribes in order to receiving notifications about a particular event specified with the event name.
| Subscribe(ContactInfo, ContactInfo, Contact, String, String, Int32) | Subscribes in order to receiving notifications about a particular event specified with the event name.
| ToString | (Inherited from Object.)
| Unregister(String, ContactInfo) | Cancels user's registration from the server.
| Unregister(String, String) | Cancels user's registration from the server.
| Unregister(String, ContactInfo, Contact) | Cancels user's registration from the server.
| Unregister(String, String, String) | Cancels user's registration from the server.
| Unsubscribe(Dialog) | Terminates existing subscription specified with the dialog.
| Unsubscribe(RequestResponse) | Terminates existing subscription.
| Unsubscribe(Response) | Terminates existing subscription specified with the response.
| Update(Dialog, SessionDescription) | Modifies the state of a session without changing the state of the dialog.
| Update(Dialog, String, String) | Modifies the state of a session without changing the state of the dialog.

Top
Events

| Name | Description
--- | --- | ---
| ReceiveRequest | Occurs when the client receives a Request.
| ReceiveResponse | Occurs when the client receives a Response.

Top
Examples
The following code example use SipClient class to connect and register to a SIP server.
Copy

    using System;
    using Independentsoft.Sip;
    namespace ConsoleApplication1
    {
    class Class1
    {
    private static Logger logger;
    private static SipClient client;
    public static void Main(string[] args)
    {
    client = new SipClient("sipdomain.com","Bob","password");
    logger = new Logger();
    logger.WriteLog += new WriteLogEventHandler(OnWriteLog);
    client.Logger = logger;
    client.ReceiveRequest += new ReceiveRequestEventHandler(OnReceiveRequest);
    client.ReceiveResponse += new ReceiveResponseEventHandler(OnReceiveResponse);
    client.Connect();
    client.Register("sip:sipdomain.com","sip:Bob@mydomain.com", "sip:Bob@mydomain.com");
    Console.WriteLine("Press ENTER to exit.");
    Console.Read();
    client.Disconnect();
    }
    private static void OnReceiveRequest(object sender, RequestEventArgs e)
    {
    //accept any request from server or another sip user agent
    client.AcceptRequest(e.Request);
    }
    private static void OnReceiveResponse(object sender,ResponseEventArgs e)
    {
    }
    private static void OnWriteLog(object sender, WriteLogEventArgs e)
    {
    Console.Write(e.Log);
    }
    }
    }

[Visual Basic]
Copy

    Imports System
    Imports Independentsoft.Sip
    Namespace ConsoleApplication1
    Class Class1
    Private Shared logger As Logger
    Private Shared client As SipClient
    Public Shared Sub Main(ByVal args() As String)
    client = New SipClient("sipdomain.com", "Bob", "password")
    logger = New Logger
    AddHandler logger.WriteLog, AddressOf OnWriteLog
    client.Logger = logger
    AddHandler client.ReceiveRequest, AddressOf OnReceiveRequest
    AddHandler client.ReceiveResponse, AddressOf OnReceiveResponse
    client.Connect()
    client.Register("sip:sipdomain.com", "sip:Bob@mydomain.com", "sip:Bob@mydomain.com")
    Console.WriteLine("Press ENTER to exit.")
    Console.Read()
    client.Disconnect()
    End Sub
    Private Shared Sub OnReceiveRequest(ByVal sender As Object, ByVal e As RequestEventArgs)
    'accept any request from server or another sip user agent
    client.AcceptRequest(e.Request)
    End Sub
    Private Shared Sub OnReceiveResponse(ByVal sender As Object, ByVal e As ResponseEventArgs)
    End Sub
    Private Shared Sub OnWriteLog(ByVal sender As Object, ByVal e As WriteLogEventArgs)
    Console.Write(e.Log)
    End Sub
    End Class
    End Namespace

See Also

#### Reference

Independentsoft.Sip Namespace

Copyright 2023 Independentsoft

Send comments on this topic to support@independentsoft.de