Exemple #1
0
        /// <summary>
        /// Constructor for creating an echo or non-positional channel.
        /// </summary>
        /// <param name="issuer">The issuer that is responsible for authorizing access to this channel</param>
        /// <param name="name">The name of the channel</param>
        /// <param name="domain">The Vivox domain that hosts this channel</param>
        /// <param name="type">The channel type</param>
        /// /// <param name="properties">3D positional channel properties.</param>
        public ChannelId(string issuer, string name, string domain, ChannelType type = ChannelType.NonPositional, Channel3DProperties properties = null)
        {
            if (string.IsNullOrEmpty(issuer))
            {
                throw new ArgumentNullException(nameof(issuer));
            }
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (string.IsNullOrEmpty(domain))
            {
                throw new ArgumentNullException(nameof(domain));
            }
            if (!Enum.IsDefined(typeof(ChannelType), type))
            {
                throw new ArgumentOutOfRangeException(type.ToString());
            }
            if (properties == null)
            {
                _properties = new Channel3DProperties();
            }
            else if (type == ChannelType.Positional && !properties.IsValid())
            {
                throw new ArgumentException("", nameof(properties));
            }
            else
            {
                _properties = properties;
            }
            if (!IsValidName(name))
            {
                throw new ArgumentException($"{GetType().Name}: Argument contains one, or more, invalid characters, or the length of the name exceeds 200 characters.", nameof(name));
            }

            _issuer = issuer;
            _name   = name;
            _domain = domain;
            _type   = type;
        }
Exemple #2
0
        public ChannelId(string uri)
        {
            if (string.IsNullOrEmpty(uri))
            {
                return;
            }
            Regex regex   = new Regex(@"sip:confctl-(e|g|d)-([^.]+).([^!|@]+)(?:!p-([^@]+))?@([^@]+)");
            var   matches = regex.Matches(uri);

            if (matches == null || matches.Count != 1 || matches[0].Groups.Count != 6)
            {
                throw new ArgumentException($"'{uri}' is not a valid URI");
            }
            var type = matches[0].Groups[1].Value;

            switch (type)
            {
            case "g":
                _type = ChannelType.NonPositional;
                break;

            case "e":
                _type = ChannelType.Echo;
                break;

            case "d":
                _type = ChannelType.Positional;
                break;

            default:
                throw new ArgumentException($"{GetType().Name}: {uri} is not a valid URI");
            }
            _issuer = matches[0].Groups[2].Value;
            _name   = matches[0].Groups[3].Value;
            if (_type == ChannelType.Positional)
            {
                _properties = new Channel3DProperties(matches[0].Groups[4].Value);
            }
            _domain = matches[0].Groups[5].Value;
        }