场景:html客户端 给 websocketpp编写的服务器(本地)发送展示URL命令(协议),这个命令会调用封装dll(展示窗口webBrowser封装在此)对应的接口。
1.问题:
无法加载URL,无法响应状态。
2.服务器相关代码:
#include <websocketpp/config/asio_no_tls.hpp>
#include <websocketpp/server.hpp>
#include <iostream>
typedef websocketpp::server<websocketpp::config::asio> server;
using websocketpp::connection_hdl;
using websocketpp::lib::placeholders::_1;
using websocketpp::lib::placeholders::_2;
using websocketpp::lib::bind;
using namespace std;
#include <set>
typedef std::set<connection_hdl,std::owner_less<connection_hdl>> con_list;
typedef server::message_ptr message_ptr;
server m_server;
con_list m_connections;
.........
m_server.init_asio();
m_server.set_message_handler(bind(&broadcast_server::on_message,this,::_1,::_2));
.......
void on_message(connection_hdl hdl, server::message_ptr msg)
{
if(g_SignDll.loadDLL())
{
g_SignDll.showHTML("https://www.baidu.com");//DLL调用
m_server.send(hdl,"succeed",msg->get_opcode());
}
else
m_server.send(hdl,"fail",msg->get_opcode());
}
2.DLL关键代码
void _stdcall ShowHTML(char* strUrl)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
AfxEnableControlContainer();
CoInitialize(NULL);
if (theApp.m_pShowDlg == NULL)//展示窗口内用webbrowser控件
{
LogInfo(_T("ShowHTML_new CShowDlg()"));
theApp.m_pShowDlg = new CShowDlg(NULL);
theApp.m_pShowDlg->Create(CShowDlg::IDD,NULL);
theApp.m_pShowDlg->ShowWindow(SW_SHOW);
theApp.m_pShowDlg->OpenNavUrl(strURL);
}
}
3.OpenNavUrl代码
void OpenNavUrl(cstring str)
{
m_ShowWeb.Navigate(str, NULL, NULL, NULL, NULL);
}
4.结果

找了半天不知道问题出现在哪里,有高手能解惑吗?
本文描述了使用WebSocketPP编写的服务器接收HTML客户端命令并尝试调用DLL中封装的WebBrowser控件展示URL的过程。遇到的问题是无法加载URL且没有响应状态,寻求解决之道。
1502

被折叠的 条评论
为什么被折叠?



