/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">Arguments not needed</param> static void Main(string[] args) { // Create transport object that will listen on the following port on the best guessed local address TransportInfo localTransport = CreateTransport(Helpers.GetLocalIP(), 3420); // Can also specify an IP if you know the IP to be used. //TransportInfo localTransport = CreateTransport("192.168.20.28", 8989); // Create an object of your SIP handling logic with the created transport SIPApp app = new SIPApp(localTransport); // Create a SIP stack with the proxy address if needed SIPStack stack = CreateStack(app,"alice","192.168.20.248", 9000); // Register with the specified user URI app.Register("sip:[email protected]"); // Simple pause so you can test each function / watch the SIP signalling Console.ReadKey(); app.Invite("*****@*****.**"); // Simple pause so you can test each function / watch the SIP signalling Console.ReadKey(); // End the current call (presuming it was accepted) app.EndCurrentCall(); // Send an example IM app.Message("*****@*****.**", "Hello, this is alice testing the SIP library"); Console.ReadKey(); }
/// <summary> /// Initializes a new instance of the <see cref="T:SIPLib.SIP.SIPStack" /> class. /// </summary> /// <param name="app">The SIPApp that messages should be passed to.</param> /// <param name="userAgentName">Name of the user agent / stack identifier.</param> public SIPStack(SIPApp app, string userAgentName = "SIPLIB") { Init(); Transport = app.Transport; App = app; App.ReceivedDataEvent += TransportReceivedDataEvent; Dialogs = new Dictionary<string, Dialog>(); app.Stack = this; _userAgentName = userAgentName; }
/// <summary> /// Creates a SIP stack. /// </summary> /// <param name="app">The associated sip application.</param> /// <param name="username">The username representing this SIP endpoint.</param> /// <param name="proxyIp">The proxy ip if any.</param> /// <param name="proxyPort">The proxy port if any.</param> /// <returns>SIPStack.</returns> public static SIPStack CreateStack(SIPApp app,string username, string proxyIp = null, int proxyPort = -1) { SIPStack myStack = new SIPStack(app) {Uri = {User = username}}; if (proxyIp != null) { myStack.ProxyHost = proxyIp; myStack.ProxyPort = (proxyPort == -1) ? 5060 : proxyPort; } return myStack; }
/// <summary> /// Initializes a new instance of the <see cref="T:SIPLib.SIP.SIPStack" /> class. /// </summary> /// <param name="app">The SIPApp that messages should be passed to.</param> /// <param name="userAgentName">Name of the user agent / stack identifier.</param> public SIPStack(SIPApp app, string userAgentName = "SIPLIB") { Init(); Transport = app.Transport; App = app; App.ReceivedDataEvent += TransportReceivedDataEvent; Dialogs = new Dictionary <string, Dialog>(); app.Stack = this; _userAgentName = userAgentName; }