Esempio n. 1
0
        /// <summary>
        /// 创建用户连接信息存储对象
        /// </summary>
        /// <param name="httpListenerContext">用户连接凭证</param>
        public WebContext(HttpListenerContext httpListenerContext)
        {
            if (httpListenerContext == null)
            {
                throw new NullReferenceException("httpListenerContext 对象不能为空!");
            }

            this.HttpListenerContext = httpListenerContext;

            IpPort = WebStateObject.GetIpPort(httpListenerContext);

            this.HttpListenerWebSocketContext = httpListenerContext.AcceptWebSocketAsync(null).GetAwaiter().GetResult();
        }
Esempio n. 2
0
        /// <summary>
        /// 创建用户连接信息存储对象
        /// </summary>
        /// <param name="httpListenerContext">用户连接凭证</param>
        /// <param name="httpListenerWebSocketContext">连接后的信息</param>
        public WebContext(HttpListenerContext httpListenerContext, HttpListenerWebSocketContext httpListenerWebSocketContext)
        {
            if (httpListenerContext == null)
            {
                throw new NullReferenceException("httpListenerContext 对象不能为空!");
            }
            if (httpListenerWebSocketContext == null)
            {
                throw new NullReferenceException("httpListenerWebSocketContext 对象不能为空!");
            }

            this.HttpListenerContext = httpListenerContext;

            IpPort = WebStateObject.GetIpPort(httpListenerContext);

            this.HttpListenerWebSocketContext = httpListenerWebSocketContext;
        }