void _test_websocket_server::send_msg(const test_websocket_msg& msg)
    {
        // Wait for the websocket server to be initialized.
        pplx::task<void>(m_server_connected).wait();
        const auto& data = msg.data();
        auto flags = websocketpp::frame::opcode::close;
        switch (msg.msg_type())
        {
        case test_websocket_message_type::WEB_SOCKET_UTF8_MESSAGE_TYPE:
            flags = websocketpp::frame::opcode::text; // WebSocket::FRAME_FLAG_FIN | WebSocket::FRAME_OP_TEXT;
            break;
        case test_websocket_message_type::WEB_SOCKET_BINARY_MESSAGE_TYPE:
            flags = websocketpp::frame::opcode::binary; // WebSocket::FRAME_FLAG_FIN | WebSocket::FRAME_OP_BINARY;
            break;
        case test_websocket_message_type::WEB_SOCKET_CLOSE_TYPE:
            flags = websocketpp::frame::opcode::close; // WebSocket::FRAME_OP_CLOSE;
            break;
		case test_websocket_message_type::WEB_SOCKET_UTF8_FRAGMENT_TYPE:
        case test_websocket_message_type::WEB_SOCKET_BINARY_FRAGMENT_TYPE:
        default:
            throw std::runtime_error("invalid message type");
        }

        std::string strmsg(data.begin(), data.end());

        if (msg.msg_type() == test_websocket_message_type::WEB_SOCKET_CLOSE_TYPE)
        {
            close(strmsg);
        }
        else
        {
            // std::cerr << "Sending message from server: " << strmsg << std::endl;
            m_srv.send(m_con, strmsg, flags);
        }
    }
int XMsgProcesser::DecodeRecvData(const char* pData, int nLen)
{
    SIGNALMSG smsg;
    MEETMSG mmsg;
    std::string err;
    std::string strmsg(pData, nLen);
    smsg.GetMsg(strmsg, err);
    if (err.length()>0) {
        LOG(LS_ERROR) << "parse SIGNALMSG err:" << err;
        return -1;
    }
    mmsg.GetMsg(smsg._scont, err);
    if (err.length()>0) {
        LOG(LS_ERROR) << "parse MEETMSG err:" << err;
        return -1;
    }
    switch (smsg._stype) {
        case SIGNALTYPE::reqlogin:
        case SIGNALTYPE::resplogin:
            DecodeLogin(smsg._stype, mmsg);
            break;
            
        case SIGNALTYPE::reqsndmsg:
        case SIGNALTYPE::respsndmsg:
            DecodeSndMsg(smsg._stype, mmsg);
            break;
            
        case SIGNALTYPE::reqgetmsg:
        case SIGNALTYPE::respgetmsg:
            DecodeGetMsg(smsg._stype, mmsg);
            break;
            
        case SIGNALTYPE::reqlogout:
        case SIGNALTYPE::resplogout:
            DecodeLogout(smsg._stype, mmsg);
            break;
            
        case SIGNALTYPE::reqkeepalive:
        case SIGNALTYPE::respkeepalive:
            DecodeKeepAlive(mmsg);
            break;
            
        default:
        LOG(LS_ERROR) << "invalid signaltype type:" << smsg._stype;
            break;
    }
    return nLen;
}
int XMsgProcesser::DecodeRecvData(const char* pData, int nLen)
{
    MEETMSG mmsg;
    std::string err;
    std::string strmsg(pData, nLen);
    mmsg.GetMsg(strmsg, err);
    if (err.length()>0) {
        LOG(LS_ERROR) << "parse MEETMSG err:" << err;
        return -1;
    }
    switch (mmsg._signaltype) {
        case SIGNALTYPE::login:
            DecodeLogin(mmsg);
            break;
            
        case SIGNALTYPE::sndmsg:
            DecodeSndMsg(mmsg);
            break;
            
        case SIGNALTYPE::getmsg:
            DecodeGetMsg(mmsg);
            break;
            
        case SIGNALTYPE::logout:
            DecodeLogout(mmsg);
            break;
            
        case SIGNALTYPE::keepalive:
            DecodeKeepAlive(mmsg);
            break;
            
        default:
        LOG(LS_ERROR) << "invalid signaltype type:" << mmsg._signaltype;
            break;
    }
    return nLen;
}