示例#1
0
        protected Boolean TryCreateReceiveBuffer(out WebSocketReceiveBuffer buffer)
        {
            lock ( m_lock )
            {
                if (State >= WebSocketState.Closed)
                {
                    buffer = default;
                    return(false);
                }

                if (IsCompressionEnabled())
                {
                    if (m_inflater == null)
                    {
                        m_inflater = new ZLibInflater();
                        m_inflater.AddRef();

                        Closed.ContinueWith(x => m_inflater.Release());
                    }
                    else
                    {
                        m_inflater.AddRef();
                    }
                }
            }

            buffer = new WebSocketReceiveBuffer(m_inflater);
            return(true);
        }
示例#2
0
        internal WebSocketReceiveBuffer(ZLibInflater inflater)
        {
            m_inflater = inflater;

            Type = WebSocketMessageType.Text;
        }