Beispiel #1
0
        /// <summary>
        /// Static constructor.
        /// </summary>
        static SipHelper()
        {
            L2C[] l2c = new L2C[] {
                new L2C(SipHeader.CallID, "i"),
                new L2C(SipHeader.Contact, "m"),
                new L2C(SipHeader.ContentEncoding, "e"),
                new L2C(SipHeader.ContentLength, "l"),
                new L2C(SipHeader.ContentType, "c"),
                new L2C(SipHeader.From, "f"),
                new L2C(SipHeader.Subject, "s"),
                new L2C(SipHeader.Supported, "k"),
                new L2C(SipHeader.To, "t"),
                new L2C(SipHeader.Via, "v"),
            };

            compactToLongHeader = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            longToCompactHeader = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (L2C map in l2c)
            {
                compactToLongHeader.Add(map.Compact, map.Long);
                longToCompactHeader.Add(map.Long, map.Compact);
            }

            allowDefault = new SipHeader("Allow", new string[] {
                "INVITE", "ACK", "CANCEL", "OPTIONS", "BYE", "REFER", "NOTIFY", "MESSAGE", "SUBSCRIBE", "INFO"
            });

            int pos = 0;

            nextTagID = Helper.ReadInt64(Crypto.Rand(8), ref pos);
        }
Beispiel #2
0
        /// <summary>
        /// Adds a header to the message, replacing any existing header
        /// with this name.
        /// </summary>
        /// <param name="header">The new header.</param>
        public void SetHeader(SipHeader header)
        {
            if (header == null)
            {
                throw new ArgumentNullException("header");
            }

            this[header.Name] = header;
        }
Beispiel #3
0
        /// <summary>
        /// Returns a deep copy of the instance.
        /// </summary>
        /// <returns>The cloned <see cref="SipHeader" />.</returns>
        public SipHeader Clone()
        {
            var clone = new SipHeader();

            clone.isSpecial = this.isSpecial;
            clone.name      = this.name;
            clone.values    = new string[this.values.Length];

            Array.Copy(this.values, clone.values, this.values.Length);

            return(clone);
        }
Beispiel #4
0
        /// <summary>
        /// Adds a header to the message, replacing any existing header
        /// with this name.
        /// </summary>
        /// <param name="name">The header name.</param>
        /// <param name="value">The new value (or <c>null</c> to remove any existing header).</param>
        public void SetHeader(string name, string value)
        {
            if (value == null)
            {
                if (headers.ContainsKey(name))
                {
                    headers.Remove(name);
                }

                return;
            }

            this[name] = new SipHeader(name, value);
        }