⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 originfield.cs

📁 pureIRCd是一个用c语音写的irc(RFC459)服务,可以给您带来很多的方便
💻 CS
字号:
namespace SDP
{
    /// <summary>
    /// An Origin represents the o= fields contained within a SessionDescription.
    /// 
    /// The Origin field identifies the originator of the session.
    /// 
    /// This is not necessarily the same entity who is involved in the session.
    /// 
    /// The Origin contains:
    ///     the name of the user originating the session,
    ///     a unique session identifier, and
    ///     a unique version for the session.
    /// 
    /// These fields should uniquely identify the session.
    /// 
    /// The Origin also includes:
    ///     the network type,
    ///     address type, and
    ///     address of the originator.
    /// </summary>
    public class OriginField : Field
    {
        /// <summary>
        /// The network type that describes the Internet.
        /// </summary>
        public const string InterNetwork = "IN";

        /// <summary>
        /// The address type for IPv4 addresses.
        /// </summary>
        public const string IPv4 = "IP4";

        /// <summary>
        /// The address type for IPv6 addresses.
        /// </summary>
        public const string IPv6 = "IP6";

        private string username;
        /// <summary>
        /// Gets the username.
        /// </summary>
        public string Username
        {
            get { return this.username; }
        }

        private long sessionId;
        /// <summary>
        /// Gets the session ID.
        /// </summary>
        public long SessionId
        {
            get { return this.sessionId; }
        }

        private long sessionVersion;
        /// <summary>
        /// Gets the version of this session.
        /// </summary>
        public long SessionVersion
        {
            get { return this.sessionVersion; }
        }

        private string address;
        /// <summary>
        /// Gets the address.
        /// </summary>
        public string Address
        {
            get { return this.address; }
        }

        private string networkType;
        /// <summary>
        /// Gets the type of network the address is using.
        /// </summary>
        public string NetworkType
        {
            get { return this.networkType; }
        }

        private string addressType;
        /// <summary>
        /// Gets the address type.
        /// </summary>
        public string AddressType
        {
            get { return this.addressType; }
        }

        /// <summary>
        /// Creates a new OriginField.
        /// </summary>
        /// <param name="value">The value portion of the field.</param>
        public OriginField(string value)
            : base("o=" + value)
        {
            string val = base.value;
            string[] parts = value.Split(' ');
            this.username = parts[0];
            this.sessionId = long.Parse(parts[1]);
            this.sessionVersion = long.Parse(parts[2]);
            this.networkType = parts[3];
            this.addressType = parts[4];
            this.address = parts[5];
        }

        /// <summary>
        /// Creates a new OriginField.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="address">The address.</param>
        /// <param name="networkType">The type of network.</param>
        /// <param name="addressType">The type of address.</param>
        public OriginField(string username, string address, string networkType, string addressType)
            : this(help(username, address, networkType, addressType)) { }

        private static string help(string username, string address, string networkType, string addressType)
        {
            return string.Format("{0} {1} {2} {3} {4} {5}", username, NtpTime.GetTime(), NtpTime.GetTime(), networkType, addressType, address);
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -