no message

This commit is contained in:
zcy 2022-03-09 16:25:04 +08:00
parent b52139cb25
commit e915fb1447
6 changed files with 82 additions and 18 deletions

View File

@ -3,7 +3,7 @@
#include "udp_form.h" #include "udp_form.h"
#include "utils.h" #include "utils.h"
#include "global.h" #include "global.h"
#include "websocket_client.h"
const std::wstring BasicForm::kClassName = L"Basic"; const std::wstring BasicForm::kClassName = L"Basic";
BasicForm::BasicForm(): BasicForm::BasicForm():
@ -200,7 +200,37 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
}); });
mMonitorNewSelect->Close(); 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<ui::TreeNode*> (ev->pSender)->GetText().c_str());
printf("GetCurSel %d\r\n", mRightSide->GetCurSel());
}
return true;
}
}
if (uMsg == WM_ADD_TCPSERVER_MONITOR) { if (uMsg == WM_ADD_TCPSERVER_MONITOR) {
TcpServerInfo* info = (TcpServerInfo*)wParam; TcpServerInfo* info = (TcpServerInfo*)wParam;
TcpServerLibevent* server = (TcpServerLibevent*)lParam; TcpServerLibevent* server = (TcpServerLibevent*)lParam;

View File

@ -19,6 +19,8 @@
#include "tcp_server_form.h" #include "tcp_server_form.h"
#include "udp_form.h" #include "udp_form.h"
#include "udp_group_form.h" #include "udp_group_form.h"
#include "websocket_client_form.h"
#include "websocket_client.h"
#include <vector> #include <vector>
#include <map> #include <map>
@ -61,6 +63,7 @@ private:
std::map<std::wstring, TcpServerFrom*> mTcpServerForm; std::map<std::wstring, TcpServerFrom*> mTcpServerForm;
std::map<std::wstring, UdpForm*> mUdpForm; std::map<std::wstring, UdpForm*> mUdpForm;
std::map<std::wstring, UdpGroupForm*> mUdpGroupForm; std::map<std::wstring, UdpGroupForm*> mUdpGroupForm;
std::map<std::wstring, WebsocketClientForm*> mWebsocketClientForm;
ui::Control* mRightShow; ui::Control* mRightShow;
}; };

View File

@ -207,20 +207,20 @@ void NewMonitorForm::InitWindow()
printf("postmessage error :%d\r\n", GetLastError()); printf("postmessage error :%d\r\n", GetLastError());
} }
} }
if (m_combo_type->GetText() == L"websocket client") { 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_ip_select->GetText().c_str());
wprintf(L"%s\r\n", m_port_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()); WebsocketClient* wsclient = new WebsocketClient(wstring2string(m_ip_select->GetText().c_str()),false);
UdpDataGramLibevent* udp = new UdpDataGramLibevent("0.0.0.0",
port, wstring2string(m_ip_select->GetText().c_str()));
TcpServerInfo* p = new TcpServerInfo; TcpServerInfo* p = new TcpServerInfo;
p->ip = m_ip_select->GetText(); p->ip = m_ip_select->GetText();
p->port = port; // p->port = port;
p->socket_fd = udp->SocketFD(); // p->socket_fd = udp->SocketFD();
printf("¿ªÆô·þÎñ¶Ë %d \r\n", p->socket_fd); printf("¿ªÆô·þÎñ¶Ë %d \r\n", p->socket_fd);
auto succ = ::PostMessage(m_parent->GetHWND(), auto succ = ::PostMessage(m_parent->GetHWND(),
WM_ADD_WEBSOCKET_SERVER, (WPARAM)p, (LPARAM)udp); WM_ADD_WEBSOCKET_CLIENT, (WPARAM)p, (LPARAM)wsclient);
if (!succ) { if (!succ) {
printf("postmessage error :%d\r\n", GetLastError()); printf("postmessage error :%d\r\n", GetLastError());
} }
@ -364,8 +364,7 @@ void NewMonitorForm::InitWindow()
} }
} }
if ((text == L"tcp client")|| (text == L"tcp server") || if ((text == L"tcp client")|| (text == L"tcp server") ||
(text == L"udp") || (text == L"udp group") || (text == L"websocket server") (text == L"udp") || (text == L"udp group") || (text == L"websocket server") || (text == L"websocket client")
|| (text == L"websocket client")
) { ) {
this->m_ip_config_vbox->SetVisible(true); this->m_ip_config_vbox->SetVisible(true);
this->m_uart_config_vbox->SetVisible(false); this->m_uart_config_vbox->SetVisible(false);
@ -373,6 +372,7 @@ void NewMonitorForm::InitWindow()
m_ip_select->SetText(L"127.0.0.1"); m_ip_select->SetText(L"127.0.0.1");
m_port_select->SetText(L"9001"); m_port_select->SetText(L"9001");
} }
} }
} }
return true; return true;

View File

@ -81,9 +81,9 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental> <LinkIncremental>true</LinkIncremental>
<IncludePath>$(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</IncludePath> <IncludePath>$(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</IncludePath>
<ReferencePath>$(ReferencePath)</ReferencePath> <ReferencePath>$(ReferencePath)</ReferencePath>
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(ProjectDir)third\lib;I:\home\.conan\data\OPENSSL\1.1.1\_\_\build\149ed843ea788702da310f9d8f34c34c2a72994a\pkgsrc\out32dll</LibraryPath> <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(ProjectDir)third\lib;E:\conan_data\OPENSSL\1.1.1\_\_\build\0ec50343443903d4bfcd42b174a43ee3f59cc16e\pkgsrc</LibraryPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
@ -124,7 +124,7 @@
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<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)</PreprocessorDefinitions> <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)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
@ -132,7 +132,7 @@
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<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;Bcrypt.lib;ssleay32.lib;libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies> <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)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">

View File

@ -1,7 +1,12 @@
#include "websocket_client_form.h" #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() WebsocketClientForm::~WebsocketClientForm()
@ -22,10 +27,36 @@ void WebsocketClientForm::Init()
m_btn_save_lua = dynamic_cast<ui::Button*>(FindSubControl(L"btn_save_lua")); m_btn_save_lua = dynamic_cast<ui::Button*>(FindSubControl(L"btn_save_lua"));
m_btn_close_form = dynamic_cast<ui::Button*>(FindSubControl(L"btn_close_uart")); 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](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() LuaDelegate* WebsocketClientForm::LuaVM()
{ {
return nullptr; return nullptr;
} }
void WebsocketClientForm::ShowDataInEdit(const char*src)
{
}

View File

@ -14,16 +14,18 @@
#include <fstream> #include <fstream>
#include "udp_libevent.h" #include "udp_libevent.h"
#include <istream> #include <istream>
#include "websocket_client.h"
class WebsocketClientForm : class WebsocketClientForm :
public ui::ChildBox, public ui::ChildBox,
LuaBindInterface LuaBindInterface
{ {
public: public:
WebsocketClientForm(ui::Window* hwnd, string url, uint32_t port, TcpClientLibevent* p); WebsocketClientForm(ui::Window* hwnd, string url, WebsocketClient* p);
~WebsocketClientForm(); ~WebsocketClientForm();
virtual void Init() override; virtual void Init() override;
LuaDelegate* LuaVM(); LuaDelegate* LuaVM();
void ShowDataInEdit(const char*);
private: private:
ui::Label* m_label_1; ui::Label* m_label_1;
ui::RichEdit* m_rich_edit_1; ui::RichEdit* m_rich_edit_1;
@ -36,10 +38,8 @@ private:
ui::CheckBox* m_check_box_2; ui::CheckBox* m_check_box_2;
ui::CheckBox* m_check_box_3; ui::CheckBox* m_check_box_3;
ui::CheckBox* m_check_box_4; ui::CheckBox* m_check_box_4;
TcpClientLibevent* mClient; WebsocketClient* mWebsocketClient;
std::fstream mLuaFileRead; std::fstream mLuaFileRead;
std::ofstream mLuaFileEdit; std::ofstream mLuaFileEdit;
}; };