public void Init() { var port = FreePort.FindNextAvailableUDPPort(15090); transport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine()); publicIPAddress = STUNClient.GetPublicIPAddress("stun.ekiga.net"); localIPEndPoint = IpAddressLookup.QueryRoutingInterface(asterisk, port); var endpoint = new IPEndPoint(localIPEndPoint.Address, port); var channel = new SIPUDPChannel(endpoint); transport.AddSIPChannel(channel); transport.SIPTransportRequestReceived += Transport_SIPTransportRequestReceived; //var registration = new SIPRegistrationUserAgent( // transport, // null, // new SIPEndPoint(SIPProtocolsEnum.udp, publicIPAddress, port), // new SIPURI("1003", asterisk, null, SIPSchemesEnum.sip, SIPProtocolsEnum.udp), // "1003", // passwords[0], // null, // asterisk, // new SIPURI(SIPSchemesEnum.sip, new SIPEndPoint(SIPProtocolsEnum.udp, publicIPAddress, port)), // 180, // null, // null, // (e) => { logger.Debug($"{ prefix } SIPRegistrationUserAgent; { e.Message }"); } // ); //registration.RegistrationSuccessful += Registration_RegistrationSuccessful; //registration.RegistrationFailed += Registration_RegistrationFailed; //registration.Start(); }
public void Init() { var port = FreePort.FindNextAvailableUDPPort(15090); transport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine()); publicIPAddress = STUNClient.GetPublicIPAddress("stun.ekiga.net"); localIPEndPoint = IpAddressLookup.QueryRoutingInterface(asterisk, port); var endpoint = new IPEndPoint(localIPEndPoint.Address, port); var channel = new SIPUDPChannel(endpoint); //channel.SIPMessageReceived += (SIPChannel sipChannel, SIPEndPoint remoteEndPoint, byte[] buffer) => { logger.Debug("Channel SIP message received " + channel.SIPChannelEndPoint + "<-" + remoteEndPoint); }; transport.AddSIPChannel(channel); for (var i = 0; i < numbers.Length; i++) { var number = numbers[i]; var password = passwords[i]; var registration = new SIPRegistrationUserAgent( transport, null, new SIPEndPoint(SIPProtocolsEnum.udp, publicIPAddress, port), new SIPURI(number, asterisk, null, SIPSchemesEnum.sip, SIPProtocolsEnum.udp), number, password, null, asterisk, new SIPURI(SIPSchemesEnum.sip, new SIPEndPoint(SIPProtocolsEnum.udp, publicIPAddress, port)), 180, null, null, (e) => { logger.Debug(e.Message); } ); logger.Debug($"{prefix} Registration attempt for {number}@{endpoint.Address}:{endpoint.Port}"); registration.RegistrationSuccessful += Registration_RegistrationSuccessful; registration.RegistrationFailed += Registration_RegistrationFailed; registration.Start(); registrations.Add(registration); } }