Beispiel #1
0
        public IAccount Register()
        {
            if (string.IsNullOrEmpty(_registrarDomain))
            {
                throw new ArgumentNullException("domain");
            }

            IAccountInternal account = CreateAccount();

            using (account.InitializationScope())
            {
                account.Credential = new NetworkCredential(_login, _password, "*");

                var sb = new SipUriBuilder();
                sb.AppendExtension(_login).AppendDomain(_registrarDomain);
                if (!string.IsNullOrEmpty(_port))
                {
                    sb.AppendPort(_port);
                }
                _transport = _transport ?? _localRegistry.SipTransport;
                if (_transport is TcpTransport)
                {
                    sb.AppendTransportSuffix(TransportType.Tcp);
                }
                else if (_transport is TlsTransport)
                {
                    sb.AppendTransportSuffix(TransportType.Tls);
                }
                account.AccountId = sb.ToString();

                sb.Clear();

                sb.AppendDomain(_registrarDomain);
                if (!string.IsNullOrEmpty(_port))
                {
                    sb.AppendPort(_port);
                }
                if (_transport is TcpTransport)
                {
                    sb.AppendTransportSuffix(TransportType.Tcp);
                }
                else if (_transport is TlsTransport)
                {
                    sb.AppendTransportSuffix(TransportType.Tls);
                }

                account.RegistrarUri = sb.ToString();
                account.SetTransport(_transport);
                account.PublishPresence = _publish;
                if (_regTimeout != default(int))
                {
                    account.RegistrationTimeout = _regTimeout;
                }
            }

            InternalRegister(account);
            return(account);
        }
        public IBuddy Register()
        {
            Helper.GuardNotNullStr(_name);
            //Helper.GuardNotNullStr(_domain);
            var buddy = CreateBuddy();

            using (buddy.InitializationScope())
            {
                var uriBuilder = new SipUriBuilder().AppendExtension(_name).AppendDomain(_domain)
                                 .AppendPort(string.IsNullOrEmpty(_port) ? "5060" : _port).AppendTransportSuffix(
                    _transport);
                buddy.Uri       = uriBuilder.ToString();
                buddy.Subscribe = _subscribe;
            }

            InternalRegister(buddy);
            return(buddy);
        }