no message
This commit is contained in:
parent
bb757480ac
commit
98fcc3c479
@ -173,12 +173,10 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
mMonitorNewSelect->Close();
|
||||
}
|
||||
|
||||
if (uMsg == WM_ADD_UDP_CLIENT_MONITOR) {
|
||||
if (uMsg == WM_ADD_UDP_MONITOR) {
|
||||
|
||||
}
|
||||
if (uMsg == WM_ADD_UDP_SERVER_MONITOR) {
|
||||
|
||||
}
|
||||
if (uMsg == WM_ADD_UART_MONITOR) {
|
||||
printf("add monitor");
|
||||
UartInfo* p = (UartInfo*)wParam;
|
||||
@ -273,18 +271,13 @@ void BasicForm::InitWindow(){
|
||||
mMonitor->GetRootNode()->AddChildNode(node);
|
||||
|
||||
node = new ui::TreeNode;
|
||||
node->SetText(nbase::StringPrintf(L"udp client"));
|
||||
node->SetClass(L"list_topitem");
|
||||
node->SetFixedHeight(30);
|
||||
|
||||
mMonitor->GetRootNode()->AddChildNode(node);
|
||||
|
||||
node = new ui::TreeNode;
|
||||
node->SetText(nbase::StringPrintf(L"udp server"));
|
||||
node->SetText(nbase::StringPrintf(L"udp"));
|
||||
node->SetClass(L"list_topitem");
|
||||
node->SetFixedHeight(30);
|
||||
mMonitor->GetRootNode()->AddChildNode(node);
|
||||
|
||||
|
||||
|
||||
node = new ui::TreeNode;
|
||||
node->SetText(nbase::StringPrintf(L"udp group"));
|
||||
node->SetClass(L"list_topitem");
|
||||
|
@ -8,5 +8,5 @@
|
||||
#define WM_ADD_UART_CLOSE (WM_USER + 6)
|
||||
#define WM_ADD_TCPSERVER_MONITOR (WM_USER + 7)
|
||||
|
||||
#define WM_ADD_UDP_CLIENT_MONITOR (WM_USER + 8)
|
||||
#define WM_ADD_UDP_SERVER_MONITOR (WM_USER + 9)
|
||||
#define WM_ADD_UDP_MONITOR (WM_USER + 8)
|
||||
#define WM_ADD_UDP_GROUP_MONITOR (WM_USER + 9)
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "serial_port.h"
|
||||
#include "base_form.h"
|
||||
#include "tcp_client.h"
|
||||
#include "udp_libevent.h"
|
||||
#include "utils.h"
|
||||
#include <string>
|
||||
|
||||
@ -133,15 +134,12 @@ void NewMonitorForm::InitWindow()
|
||||
|
||||
}
|
||||
}
|
||||
if (m_combo_type->GetText() == L"udp client") {
|
||||
|
||||
if (m_combo_type->GetText() == L"udp") {
|
||||
wprintf(L"%s\r\n", m_ip_select->GetText().c_str());
|
||||
wprintf(L"%s\r\n", m_port_select->GetText().c_str());
|
||||
|
||||
}
|
||||
if (m_combo_type->GetText() == L"udp server") {
|
||||
wprintf(L"%s\r\n", m_ip_select->GetText().c_str());
|
||||
wprintf(L"%s\r\n", m_port_select->GetText().c_str());
|
||||
}
|
||||
if (m_combo_type->GetText() == L"tcp client") {
|
||||
wprintf(L"%s\r\n", m_ip_select->GetText().c_str());
|
||||
wprintf(L"%s\r\n", m_port_select->GetText().c_str());
|
||||
@ -183,10 +181,23 @@ void NewMonitorForm::InitWindow()
|
||||
|
||||
|
||||
|
||||
if (m_combo_type->GetText() == L"udp client") {
|
||||
if (m_combo_type->GetText() == L"udp") {
|
||||
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(wstring2string(m_ip_select->GetText().c_str()), port);
|
||||
TcpServerInfo* p = new TcpServerInfo;
|
||||
p->ip = m_ip_select->GetText();
|
||||
p->port = port;
|
||||
p->socket_fd = m_tcp_server->SocketFd();
|
||||
|
||||
printf("¿ªÆô·þÎñ¶Ë %d \r\n", p->socket_fd);
|
||||
|
||||
auto succ = ::PostMessage(m_parent->GetHWND(),
|
||||
WM_ADD_UDP_MONITOR, (WPARAM)p, (LPARAM)udp);
|
||||
if (!succ) {
|
||||
printf("postmessage error :%d\r\n", GetLastError());
|
||||
}
|
||||
if (m_combo_type->GetText() == L"udp server") {
|
||||
|
||||
}
|
||||
return true;
|
||||
@ -234,7 +245,7 @@ void NewMonitorForm::InitWindow()
|
||||
element->SetFixedHeight(30);
|
||||
element->SetBkColor(L"white");
|
||||
element->SetTextPadding({ 6,0,6,0 });
|
||||
element->SetText(nbase::StringPrintf(L"udp client"));
|
||||
element->SetText(nbase::StringPrintf(L"udp"));
|
||||
m_combo_type->Add(element);
|
||||
|
||||
element = new ui::ListContainerElement;
|
||||
@ -242,7 +253,7 @@ void NewMonitorForm::InitWindow()
|
||||
element->SetFixedHeight(30);
|
||||
element->SetBkColor(L"white");
|
||||
element->SetTextPadding({ 6,0,6,0 });
|
||||
element->SetText(nbase::StringPrintf(L"udp server"));
|
||||
element->SetText(nbase::StringPrintf(L"udp group"));
|
||||
m_combo_type->Add(element);
|
||||
}
|
||||
m_ip_config_vbox = dynamic_cast<ui::VBox*>(FindControl(L"ip_config"));
|
||||
@ -267,7 +278,6 @@ void NewMonitorForm::InitWindow()
|
||||
if (ev->Type == 42) {
|
||||
auto text = p->GetText();
|
||||
wprintf(L"%s\r\n", text.c_str());
|
||||
|
||||
if (text == L"uart") {
|
||||
this->m_ip_config_vbox->SetVisible(false);
|
||||
this->m_uart_config_vbox->SetVisible(true);
|
||||
|
@ -174,7 +174,7 @@
|
||||
<ClCompile Include="tcp_client_form.cpp" />
|
||||
<ClCompile Include="tcp_server_libevent.cpp" />
|
||||
<ClCompile Include="uart_form.cpp" />
|
||||
<ClCompile Include="udp_client_libevent.cpp" />
|
||||
<ClCompile Include="udp_libevent.cpp" />
|
||||
<ClCompile Include="utils.cpp" />
|
||||
<ClCompile Include="lua_bind.cpp" />
|
||||
</ItemGroup>
|
||||
@ -190,8 +190,9 @@
|
||||
<ClInclude Include="serial_port.h" />
|
||||
<ClInclude Include="tcp_server_form.h" />
|
||||
<ClInclude Include="tcp_client_form.h" />
|
||||
<ClInclude Include="tcp_server_libevent.h" />
|
||||
<ClInclude Include="uart_process.h" />
|
||||
<ClInclude Include="udp_client_libevent.h" />
|
||||
<ClInclude Include="udp_libevent.h" />
|
||||
<ClInclude Include="utils.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -57,7 +57,7 @@
|
||||
<ClCompile Include="global.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="udp_client_libevent.cpp">
|
||||
<ClCompile Include="udp_libevent.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
@ -101,7 +101,10 @@
|
||||
<ClInclude Include="global.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="udp_client_libevent.h">
|
||||
<ClInclude Include="tcp_server_libevent.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="udp_libevent.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
@ -1,8 +0,0 @@
|
||||
#include "udp_client_libevent.h"
|
||||
|
||||
UdpClientLibevent::UdpClientLibevent(std::string ipaddr, uint32_t port)
|
||||
{
|
||||
this->m_bind_ip = ipaddr;
|
||||
this->m_port = m_port;
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#include <WinSock2.h>
|
||||
#endif
|
||||
|
||||
#ifdef linux
|
||||
#include<sys/types.h>
|
||||
#include<sys/socket.h>
|
||||
#include<arpa/inet.h>
|
||||
#define EVENT__HAVE_PTHREADS
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <map>
|
||||
#include <functional>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class UdpClientLibevent
|
||||
{
|
||||
UdpClientLibevent(std::string ipaddr,uint32_t port);
|
||||
|
||||
private:
|
||||
uint32_t m_port; // 监听端口号
|
||||
string m_bind_ip; // 绑定端口号
|
||||
int m_current_conection; // 当前连接数目
|
||||
uint16_t m_backlog;
|
||||
struct sockaddr_in m_server_addr; // 服务器地址
|
||||
struct event_base* m_event_base;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user