no message

This commit is contained in:
zcy 2022-03-14 00:05:00 +08:00
parent 021f1653b7
commit 7065ee909e
5 changed files with 48 additions and 5 deletions

View File

@ -172,9 +172,7 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
//delete mRightShow;
mRightShow = nullptr;
}
if (uMsg == WM_USER_POS_CHANGED) {
}
if (uMsg == WM_ADD_TCPCLIENT_MONITOR) {
TcpClientInfo* info = (TcpClientInfo*)wParam;
TcpClientLibevent* cli = (TcpClientLibevent*)lParam;
@ -383,6 +381,26 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
);
mMonitorNewSelect->Close();
}
if (uMsg == WM_ADD_WEBSOCKET_SERVER_CLOSE) {
wprintf(L"close %s\r\n", ((wstring*)wParam)->c_str());
mRightShow->SetVisible(false);
mRightSide->RemoveAll();
mWebsocketServerForm.erase(*(wstring*)(wParam));
int cnt = mMonitor->GetRootNode()->GetChildNode(6)->GetChildNodeCount();
ui::TreeNode* p = nullptr;
for (int i = 0; i < cnt; i++) {
if (mMonitor->GetRootNode()->GetChildNode(6)->GetChildNode(i)->GetText()
== *(wstring*)(wParam)) {
p = mMonitor->GetRootNode()->GetChildNode(6)->GetChildNode(i);
break;
}
}
if (nullptr != p)
mMonitor->GetRootNode()->GetChildNode(6)->RemoveChildNode(p);
//delete mRightShow;
mRightShow = nullptr;
}
if (uMsg == WM_ADD_UDP_MONITOR) {
printf("add udp monitor");
wchar_t pdata[100] = L"\0";

View File

@ -98,6 +98,18 @@ WebsocketServer::WebsocketServer(std::string server,uint32_t port){
});
}
WebsocketServer::~WebsocketServer()
{
/*
this->m_status = WebsocketClient::STOP;
if (m_tls)
m_client_tls.stop();
else
m_client.stop();
m_thread->join();
*/
}
int WebsocketServer::SendData(uint32_t fd,const char* dat,int len,
websocketpp::frame::opcode::value op){

View File

@ -18,6 +18,7 @@ typedef WsServer::message_ptr message_ptr;
class WebsocketServer {
public:
typedef std::function<void(std::string addr, uint32_t port)> OnNewConnectionHanlder;
typedef std::function<void(std::string addr, uint32_t port)> OnConnectionCloseHanlder;
typedef std::function<void(std::string addr, uint32_t port,std::string message)> OnMessageHanlder;
@ -25,6 +26,7 @@ public:
std::string Url();
uint32_t Port();
WebsocketServer(std::string server,uint32_t port);
~WebsocketServer();
friend void on_new_connection(WebsocketServer* s, websocketpp::connection_hdl hdl);
friend void on_message(WebsocketServer* s, websocketpp::connection_hdl hdl, message_ptr msg);
friend void on_connection_close(WebsocketServer* s, websocketpp::connection_hdl hdl);

View File

@ -26,6 +26,13 @@ WebsocketServerForm::WebsocketServerForm(ui::Window* hwnd, string url,
this->mLua->BindFunction("showdata", LuaShowData);
}
WebsocketServerForm::~WebsocketServerForm()
{
std::cout << "~WebsocketServerForm\r\n";
std::cout << "~WebsocketServerForm\r\n";
}
void WebsocketServerForm::Init()
{
ui::ChildBox::Init();
@ -68,10 +75,13 @@ void WebsocketServerForm::Init()
m_btn_close_form = dynamic_cast<ui::Button*>(FindSubControl(L"btn_close_uart"));
if (nullptr != m_btn_close_form) {
m_btn_close_form->AttachClick([this](ui::EventArgs *ev) {
m_btn_close_form->AttachClick([this](ui::EventArgs* ev) {
wstring* name = new wstring(this->GetName());
::PostMessage(this->GetWindow()->GetHWND(),
WM_ADD_WEBSOCKET_SERVER_CLOSE, (WPARAM)name, 0);
return true;
});
});
}
if (nullptr != m_btn_save_lua)
m_btn_save_lua->AttachClick(
[this](ui::EventArgs* ev) {

View File

@ -26,6 +26,7 @@ class WebsocketServerForm :
public:
WebsocketServerForm(ui::Window* hwnd,
string url, WebsocketServer* server);
~WebsocketServerForm();
virtual void Init() override;
LuaDelegate* LuaVM();
void ShowDataInEdit(const char*) ;