From e915fb1447a02b6531c8afbb81068b6be5f50420 Mon Sep 17 00:00:00 2001 From: zcy <290198252@qq.com> Date: Wed, 9 Mar 2022 16:25:04 +0800 Subject: [PATCH] no message --- examples/proto_debuger/base_form.cpp | 32 +++++++++++++++++- examples/proto_debuger/base_form.h | 3 ++ examples/proto_debuger/new_monitor_form.cpp | 16 ++++----- examples/proto_debuger/proto_debuger.vcxproj | 8 ++--- .../proto_debuger/websocket_client_form.cpp | 33 ++++++++++++++++++- .../proto_debuger/websocket_client_form.h | 8 ++--- 6 files changed, 82 insertions(+), 18 deletions(-) diff --git a/examples/proto_debuger/base_form.cpp b/examples/proto_debuger/base_form.cpp index 136885bd..5c9378a1 100644 --- a/examples/proto_debuger/base_form.cpp +++ b/examples/proto_debuger/base_form.cpp @@ -3,7 +3,7 @@ #include "udp_form.h" #include "utils.h" #include "global.h" - +#include "websocket_client.h" const std::wstring BasicForm::kClassName = L"Basic"; BasicForm::BasicForm(): @@ -200,7 +200,37 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) }); mMonitorNewSelect->Close(); } + if (uMsg == WM_ADD_WEBSOCKET_CLIENT) { + TcpServerInfo* info = (TcpServerInfo*)wParam; + ui::TreeNode* node = new ui::TreeNode; + mMonitor->GetRootNode()->GetChildNode(5)->AddChildNode(node); + auto key = info->ip; + node->SetText(key); + node->SetClass(L"listitem"); + + if (mWebsocketClientForm.find(info->ip) == mWebsocketClientForm.end()) + { + WebsocketClient* client = (WebsocketClient*)lParam; + + auto form = new WebsocketClientForm(this, wstring2string(info->ip),client); + form->SetChildLayoutXML(L"basic/tcp_server_form.xml"); + form->SetName(key); + form->SetVisible(false); + mWebsocketClientForm[key] = form; + if (!mRightSide->Add(form)) + printf("error 1"); + } + node->AttachAllEvents( + [this](ui::EventArgs* ev) { + if (ui::EventType::kEventSelect == ev->Type) { + wprintf(L"%s\r\n", dynamic_cast (ev->pSender)->GetText().c_str()); + printf("GetCurSel %d\r\n", mRightSide->GetCurSel()); + + } + return true; + } + } if (uMsg == WM_ADD_TCPSERVER_MONITOR) { TcpServerInfo* info = (TcpServerInfo*)wParam; TcpServerLibevent* server = (TcpServerLibevent*)lParam; diff --git a/examples/proto_debuger/base_form.h b/examples/proto_debuger/base_form.h index fd3464c9..2d102333 100644 --- a/examples/proto_debuger/base_form.h +++ b/examples/proto_debuger/base_form.h @@ -19,6 +19,8 @@ #include "tcp_server_form.h" #include "udp_form.h" #include "udp_group_form.h" +#include "websocket_client_form.h" +#include "websocket_client.h" #include #include @@ -61,6 +63,7 @@ private: std::map mTcpServerForm; std::map mUdpForm; std::map mUdpGroupForm; + std::map mWebsocketClientForm; ui::Control* mRightShow; }; diff --git a/examples/proto_debuger/new_monitor_form.cpp b/examples/proto_debuger/new_monitor_form.cpp index d7536983..fc57589b 100644 --- a/examples/proto_debuger/new_monitor_form.cpp +++ b/examples/proto_debuger/new_monitor_form.cpp @@ -207,20 +207,20 @@ void NewMonitorForm::InitWindow() printf("postmessage error :%d\r\n", GetLastError()); } } + if (m_combo_type->GetText() == L"websocket client") { wprintf(L"%s\r\n", m_ip_select->GetText().c_str()); wprintf(L"%s\r\n", m_port_select->GetText().c_str()); - int port = atoi(wstring2string(m_port_select->GetText()).c_str()); - UdpDataGramLibevent* udp = new UdpDataGramLibevent("0.0.0.0", - port, wstring2string(m_ip_select->GetText().c_str())); + WebsocketClient* wsclient = new WebsocketClient(wstring2string(m_ip_select->GetText().c_str()),false); + TcpServerInfo* p = new TcpServerInfo; p->ip = m_ip_select->GetText(); - p->port = port; - p->socket_fd = udp->SocketFD(); + // p->port = port; + // p->socket_fd = udp->SocketFD(); printf("¿ªÆô·þÎñ¶Ë %d \r\n", p->socket_fd); auto succ = ::PostMessage(m_parent->GetHWND(), - WM_ADD_WEBSOCKET_SERVER, (WPARAM)p, (LPARAM)udp); + WM_ADD_WEBSOCKET_CLIENT, (WPARAM)p, (LPARAM)wsclient); if (!succ) { printf("postmessage error :%d\r\n", GetLastError()); } @@ -364,8 +364,7 @@ void NewMonitorForm::InitWindow() } } if ((text == L"tcp client")|| (text == L"tcp server") || - (text == L"udp") || (text == L"udp group") || (text == L"websocket server") - || (text == L"websocket client") + (text == L"udp") || (text == L"udp group") || (text == L"websocket server") || (text == L"websocket client") ) { this->m_ip_config_vbox->SetVisible(true); this->m_uart_config_vbox->SetVisible(false); @@ -373,6 +372,7 @@ void NewMonitorForm::InitWindow() m_ip_select->SetText(L"127.0.0.1"); m_port_select->SetText(L"9001"); } + } } return true; diff --git a/examples/proto_debuger/proto_debuger.vcxproj b/examples/proto_debuger/proto_debuger.vcxproj index 717f62cc..4d445ef4 100644 --- a/examples/proto_debuger/proto_debuger.vcxproj +++ b/examples/proto_debuger/proto_debuger.vcxproj @@ -81,9 +81,9 @@ true - $(VC_IncludePath);$(WindowsSDK_IncludePath);..\..\;$(ProjectDir)third\include\libevent\include;$(ProjectDir);$(ProjectDir)third\include\lua;$(ProjectDir)third\include\;D:\include;I:\home\.conan\data\OPENSSL\1.1.1\_\_\build\149ed843ea788702da310f9d8f34c34c2a72994a\pkgsrc\inc32 + $(VC_IncludePath);$(WindowsSDK_IncludePath);..\..\;$(ProjectDir)third\include\libevent\include;$(ProjectDir);$(ProjectDir)third\include\lua;$(ProjectDir)third\include\;D:\include;E:\conan_data\OPENSSL\1.1.1\_\_\build\0ec50343443903d4bfcd42b174a43ee3f59cc16e\pkgsrc\include $(ReferencePath) - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(ProjectDir)third\lib;I:\home\.conan\data\OPENSSL\1.1.1\_\_\build\149ed843ea788702da310f9d8f34c34c2a72994a\pkgsrc\out32dll + $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(ProjectDir)third\lib;E:\conan_data\OPENSSL\1.1.1\_\_\build\0ec50343443903d4bfcd42b174a43ee3f59cc16e\pkgsrc false @@ -124,7 +124,7 @@ Level3 true - _WEBSOCKETPP_CPP11_TYPE_TRAITS_;_WEBSOCKETPP_CPP11_RANDOM_DEVICE_;ASIO_STANDALONE ;_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;_WSPIAPI_H_;_WINSOCKAPI_;%(PreprocessorDefinitions) + _WEBSOCKETPP_CPP11_TYPE_TRAITS_;_WEBSOCKETPP_CPP11_RANDOM_DEVICE_;ASIO_STANDALONE;_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;_WSPIAPI_H_;_WINSOCKAPI_;%(PreprocessorDefinitions) true MultiThreadedDebug /bigobj %(AdditionalOptions) @@ -132,7 +132,7 @@ Windows true - ws2_32.lib;event_extra.lib;event_core.lib;event.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;lua53.lib;Bcrypt.lib;ssleay32.lib;libeay32.lib;%(AdditionalDependencies) + ws2_32.lib;event_extra.lib;event_core.lib;event.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;lua53.lib;libcrypto_static.lib;libssl_static.lib;Bcrypt.lib;libcmtd.lib;%(AdditionalDependencies) diff --git a/examples/proto_debuger/websocket_client_form.cpp b/examples/proto_debuger/websocket_client_form.cpp index 4f4018f3..2f65eada 100644 --- a/examples/proto_debuger/websocket_client_form.cpp +++ b/examples/proto_debuger/websocket_client_form.cpp @@ -1,7 +1,12 @@ #include "websocket_client_form.h" -WebsocketClientForm::WebsocketClientForm(ui::Window* hwnd, string url, uint32_t port, TcpClientLibevent* p) +WebsocketClientForm::WebsocketClientForm(ui::Window* hwnd, string url, WebsocketClient* p) { + if (nullptr != hwnd) { + this->SetWindow(hwnd, nullptr, false); + } + mWebsocketClient = p; + } WebsocketClientForm::~WebsocketClientForm() @@ -22,10 +27,36 @@ void WebsocketClientForm::Init() m_btn_save_lua = dynamic_cast(FindSubControl(L"btn_save_lua")); m_btn_close_form = dynamic_cast(FindSubControl(L"btn_close_uart")); + if (nullptr != m_btn_close_form) + m_btn_close_form->AttachClick([this](const ui::EventArgs *ev) { + + + return true; + } + ); + if(nullptr != m_btn_save_lua) + m_btn_save_lua->AttachClick( + [this](ui::EventArgs* ev) + { + return true; + } + ); + if (nullptr != m_btn_send_data) { + m_btn_send_data->AttachClick([this](const ui::EventArgs* ev) { + + return true; + }); + + } } LuaDelegate* WebsocketClientForm::LuaVM() { return nullptr; } + +void WebsocketClientForm::ShowDataInEdit(const char*src) +{ + +} diff --git a/examples/proto_debuger/websocket_client_form.h b/examples/proto_debuger/websocket_client_form.h index ff4b4146..9c8ef059 100644 --- a/examples/proto_debuger/websocket_client_form.h +++ b/examples/proto_debuger/websocket_client_form.h @@ -14,16 +14,18 @@ #include #include "udp_libevent.h" #include +#include "websocket_client.h" class WebsocketClientForm : public ui::ChildBox, LuaBindInterface { public: - WebsocketClientForm(ui::Window* hwnd, string url, uint32_t port, TcpClientLibevent* p); + WebsocketClientForm(ui::Window* hwnd, string url, WebsocketClient* p); ~WebsocketClientForm(); virtual void Init() override; LuaDelegate* LuaVM(); + void ShowDataInEdit(const char*); private: ui::Label* m_label_1; ui::RichEdit* m_rich_edit_1; @@ -36,10 +38,8 @@ private: ui::CheckBox* m_check_box_2; ui::CheckBox* m_check_box_3; ui::CheckBox* m_check_box_4; - TcpClientLibevent* mClient; + WebsocketClient* mWebsocketClient; std::fstream mLuaFileRead; std::ofstream mLuaFileEdit; - - };