private void ReceivedHanlder(SegmentToken session)
        {
            if (IsConnected == false)
            {
                string msg = encoding.GetString(session.Data.buffer, session.Data.offset, session.Data.size);
                acceptInfo = new WebsocketFrame().ParseAcceptedFrame(msg);

                if ((IsConnected = acceptInfo.IsHandShaked()))
                {
                    resetEvent.Set();
                    if (OnConnected != null)
                    {
                        OnConnected(session.sToken, IsConnected);
                    }
                }
                else
                {
                    clientProvider.Disconnect();
                }
            }
            else
            {
                WebsocketFrame packet = new WebsocketFrame();
                bool           isOk   = packet.DecodingFromBytes(session.Data, true);
                if (isOk == false)
                {
                    return;
                }

                if (packet.OpCode == 0x01)
                {
                    if (OnReceived != null)
                    {
                        OnReceived(session.sToken, encoding.GetString(packet.Payload.buffer,
                                                                      packet.Payload.offset, packet.Payload.size));
                    }

                    return;
                }
                else if (packet.OpCode == 0x08)//close
                {
                    IsConnected = false;
                    clientProvider.Disconnect();
                }
                else if (packet.OpCode == 0x09)//ping
                {
                    SendPong(session.Data);
                }
                else if (packet.OpCode == 0x0A)//pong
                {
                    SendPing();
                }

                if (OnReceivedBytes != null && packet.Payload.size > 0)
                {
                    OnReceivedBytes(new SegmentToken(session.sToken, packet.Payload));
                }
            }
        }