no message
This commit is contained in:
parent
278630d881
commit
7f9c6c2733
@ -348,7 +348,9 @@ 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"udp") || (text == L"udp group") || (text == L"websocket server")
|
||||||
|
|| (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);
|
||||||
|
|
||||||
|
@ -180,6 +180,7 @@
|
|||||||
<ClCompile Include="utils.cpp" />
|
<ClCompile Include="utils.cpp" />
|
||||||
<ClCompile Include="lua_bind.cpp" />
|
<ClCompile Include="lua_bind.cpp" />
|
||||||
<ClCompile Include="websocket_client.cpp" />
|
<ClCompile Include="websocket_client.cpp" />
|
||||||
|
<ClCompile Include="websocket_client_form.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="base_form.h" />
|
<ClInclude Include="base_form.h" />
|
||||||
@ -200,6 +201,7 @@
|
|||||||
<ClInclude Include="udp_libevent.h" />
|
<ClInclude Include="udp_libevent.h" />
|
||||||
<ClInclude Include="utils.h" />
|
<ClInclude Include="utils.h" />
|
||||||
<ClInclude Include="websocket_client.h" />
|
<ClInclude Include="websocket_client.h" />
|
||||||
|
<ClInclude Include="websocket_client_form.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Xml Include="..\Debug\resources\themes\default\basic\basic.xml" />
|
<Xml Include="..\Debug\resources\themes\default\basic\basic.xml" />
|
||||||
|
@ -66,6 +66,12 @@
|
|||||||
<ClCompile Include="udp_group_form.cpp">
|
<ClCompile Include="udp_group_form.cpp">
|
||||||
<Filter>源文件</Filter>
|
<Filter>源文件</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="websocket_client.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="websocket_client_form.cpp">
|
||||||
|
<Filter>源文件</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="main.h">
|
<ClInclude Include="main.h">
|
||||||
@ -119,6 +125,12 @@
|
|||||||
<ClInclude Include="udp_group_form.h">
|
<ClInclude Include="udp_group_form.h">
|
||||||
<Filter>头文件</Filter>
|
<Filter>头文件</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="websocket_client.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="websocket_client_form.h">
|
||||||
|
<Filter>头文件</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Xml Include="..\Debug\resources\themes\default\basic\basic.xml">
|
<Xml Include="..\Debug\resources\themes\default\basic\basic.xml">
|
||||||
|
@ -26,7 +26,6 @@ class TcpClientForm :
|
|||||||
public ui::ChildBox,
|
public ui::ChildBox,
|
||||||
public TcpClientLibevent::TcpClientObserver,
|
public TcpClientLibevent::TcpClientObserver,
|
||||||
public LuaBindInterface {
|
public LuaBindInterface {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TcpClientForm(ui::Window* hwnd,string url, uint32_t port, TcpClientLibevent* p);
|
TcpClientForm(ui::Window* hwnd,string url, uint32_t port, TcpClientLibevent* p);
|
||||||
~TcpClientForm();
|
~TcpClientForm();
|
||||||
|
@ -18,7 +18,6 @@ TcpServerFrom::~TcpServerFrom() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TcpServerFrom::TcpServerFrom(ui::Window* hwnd, string url,
|
TcpServerFrom::TcpServerFrom(ui::Window* hwnd, string url,
|
||||||
uint32_t port, TcpServerLibevent* p):
|
uint32_t port, TcpServerLibevent* p):
|
||||||
mLua(nullptr)
|
mLua(nullptr)
|
||||||
|
@ -1,39 +1 @@
|
|||||||
require("string")
|
require("string")
local file = io.open("writetest.txt", "w+")
function OnUartData(data)
if nil == file then
print("open file writetest.txt fail")
end
file:write("OnUartData from lua " .. data)
file:flush()
showdata("dfasdfsddfasda" .. data)
end
-- function OnNetworkData(addr,data,len)
-- print(addr,data,len)
-- print(len)
-- print(data)
-- -- showbuffer("recv network data: " .. data .. "\r\n")
-- end
-- function OnUdpData(addr,data,len)
-- print(addr,data,len)
-- -- showbuffer("recv data: ",data,"\r\n")
-- end
-- function OnNewClient(addr,port,sock)
-- print(addr,port,sock)
-- -- showbuffer("tcp connected: "
-- -- ..addr.."\r\n"..port.."\r\n"..sock.."\r\n")
-- end
-- function OnClientLeave(addr,port,sock)
-- print(addr,port,sock)
-- -- showbuffer("tcp close: "
-- -- ..addr.."\r\n"..port.."\r\n"..sock.."\r\n")
-- end
|
||||||
local file = io.open("writetest.txt", "w+")
|
|
||||||
|
|
||||||
function OnUartData(data)
|
|
||||||
if nil == file then
|
|
||||||
print("open file writetest.txt fail")
|
|
||||||
end
|
|
||||||
file:write("OnUartData from lua " .. data)
|
|
||||||
file:flush()
|
|
||||||
showdata("OnUartData from lua " .. data)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- function OnNetworkData(addr,data,len)
|
|
||||||
-- print(addr,data,len)
|
|
||||||
-- print(len)
|
|
||||||
-- print(data)
|
|
||||||
-- -- showbuffer("recv network data: " .. data .. "\r\n")
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- function OnUdpData(addr,data,len)
|
|
||||||
-- print(addr,data,len)
|
|
||||||
-- -- showbuffer("recv data: ",data,"\r\n")
|
|
||||||
-- end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- function OnNewClient(addr,port,sock)
|
|
||||||
-- print(addr,port,sock)
|
|
||||||
-- -- showbuffer("tcp connected: "
|
|
||||||
-- -- ..addr.."\r\n"..port.."\r\n"..sock.."\r\n")
|
|
||||||
-- end
|
|
||||||
|
|
||||||
|
|
||||||
-- function OnClientLeave(addr,port,sock)
|
|
||||||
-- print(addr,port,sock)
|
|
||||||
-- -- showbuffer("tcp close: "
|
|
||||||
-- -- ..addr.."\r\n"..port.."\r\n"..sock.."\r\n")
|
|
||||||
-- end
|
|
||||||
|
|
@ -19,8 +19,6 @@ void on_message(client* c, websocketpp::connection_hdl hdl, message_ptr msg) {
|
|||||||
std::cout << "on_message called with hdl: " << hdl.lock().get()
|
std::cout << "on_message called with hdl: " << hdl.lock().get()
|
||||||
<< " and message: " << msg->get_payload()
|
<< " and message: " << msg->get_payload()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
|
|
||||||
websocketpp::lib::error_code ec;
|
websocketpp::lib::error_code ec;
|
||||||
|
|
||||||
c->send(hdl, msg->get_payload(), msg->get_opcode(), ec);
|
c->send(hdl, msg->get_payload(), msg->get_opcode(), ec);
|
||||||
|
29
examples/proto_debuger/websocket_client_form.cpp
Normal file
29
examples/proto_debuger/websocket_client_form.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include "websocket_client_form.h"
|
||||||
|
|
||||||
|
WebsocketClientForm::WebsocketClientForm(ui::Window* hwnd, string url, uint32_t port, TcpClientLibevent* p)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
WebsocketClientForm::~WebsocketClientForm()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebsocketClientForm::Init()
|
||||||
|
{
|
||||||
|
ui::ChildBox::Init();
|
||||||
|
m_label_1 = dynamic_cast<ui::Label*>(FindSubControl(L"uart_info_label"));
|
||||||
|
m_rich_edit_1 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_recv_eidt"));
|
||||||
|
m_rich_edit_2 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"lua_script"));
|
||||||
|
m_uart_send_edit = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_send_edit"));
|
||||||
|
m_btn_send_data = dynamic_cast<ui::Button*>(FindSubControl(L"btn_send_data"));
|
||||||
|
m_check_box_2 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_time_send"));
|
||||||
|
m_check_box_3 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_hex_send"));
|
||||||
|
m_check_box_4 = dynamic_cast<ui::CheckBox*>(FindSubControl(L"check_hex_recv"));
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
|
||||||
|
LuaDelegate* WebsocketClientForm::LuaVM()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
49
examples/proto_debuger/websocket_client_form.h
Normal file
49
examples/proto_debuger/websocket_client_form.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include "msgdef.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
#include "base/base.h"
|
||||||
|
#include "serial_port.h"
|
||||||
|
#include "duilib/UIlib.h"
|
||||||
|
#include "tcp_client.h"
|
||||||
|
#include "lua_wraper.h"
|
||||||
|
#include "global.h"
|
||||||
|
#include <fstream>
|
||||||
|
#include "udp_libevent.h"
|
||||||
|
#include <istream>
|
||||||
|
|
||||||
|
class WebsocketClientForm :
|
||||||
|
public ui::ChildBox,
|
||||||
|
LuaBindInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebsocketClientForm(ui::Window* hwnd, string url, uint32_t port, TcpClientLibevent* p);
|
||||||
|
~WebsocketClientForm();
|
||||||
|
virtual void Init() override;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LuaDelegate* LuaVM();
|
||||||
|
|
||||||
|
private:
|
||||||
|
ui::Label* m_label_1;
|
||||||
|
ui::RichEdit* m_rich_edit_1;
|
||||||
|
ui::RichEdit* m_rich_edit_2;
|
||||||
|
ui::RichEdit* m_uart_send_edit;
|
||||||
|
ui::Button* m_btn_send_data;
|
||||||
|
ui::Button* m_btn_save_lua;
|
||||||
|
ui::Button* m_btn_close_form;
|
||||||
|
ui::CheckBox* m_check_box_1;
|
||||||
|
ui::CheckBox* m_check_box_2;
|
||||||
|
ui::CheckBox* m_check_box_3;
|
||||||
|
ui::CheckBox* m_check_box_4;
|
||||||
|
TcpClientLibevent* mClient;
|
||||||
|
std::fstream mLuaFileRead;
|
||||||
|
std::ofstream mLuaFileEdit;
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user