protected void DoSendPongMessage()
        {
            WSFrame wsFrame = WSFrame.CreateFrame(WSFrameType.Pong, this.options.MaskingEnabled, "Hello");

            this.LogBufferContent("Sending pong frame: ", wsFrame.FrameData, 0, wsFrame.FrameData.Length);
            this.socketStream.Write(wsFrame.FrameData, 0, wsFrame.FrameData.Length);
        }
        protected void DoSendCloseFrame()
        {
            WSFrame wsFrame = WSFrame.CreateFrame(WSFrameType.Close, this.options.MaskingEnabled, ArrayUtil.Concat(this.closeStatus, this.closeReason));

            this.LogBufferContent("Sending close frame: ", wsFrame.FrameData, 0, wsFrame.FrameData.Length);
            this.socketStream.Write(wsFrame.FrameData, 0, wsFrame.FrameData.Length);
            this.subState = SubState.WaitForCloseResponse;
        }
        protected void EnqueueMessage(WSFrameType opCode, bool isMasked, byte[] payLoad, bool highPriority = false)
        {
            WSFrame wsFrame = WSFrame.CreateFrame(opCode, isMasked, payLoad);

            if (highPriority)
            {
                this.sendQueue.Poke(wsFrame);
            }
            else
            {
                this.sendQueue.Enqueue(wsFrame);
            }
        }
        protected void DoSendCloseResponse()
        {
            byte[] payLoad = null;
            if (this.lastRcvdFrame.OpCode == WSFrameType.Close && this.lastRcvdFrame.PayloadLength > 0)
            {
                // reply with the same status code and reason
                payLoad = this.lastRcvdFrame.PayloadBytes;
            }

            WSFrame wsFrame = WSFrame.CreateFrame(WSFrameType.Close, this.options.MaskingEnabled, payLoad);

            this.LogBufferContent("Sending close frame: ", wsFrame.FrameData, 0, wsFrame.FrameData.Length);
            this.socketStream.Write(wsFrame.FrameData, 0, wsFrame.FrameData.Length);
            this.socketStream.Flush();

            this.subState = SubState.CloseTcpConnection;
        }