no message
This commit is contained in:
parent
5f70c4333f
commit
9b6195eb1e
@ -14,8 +14,6 @@ UdpForm::~UdpForm()
|
|||||||
void UdpForm::Init()
|
void UdpForm::Init()
|
||||||
{
|
{
|
||||||
ui::ChildBox::Init();
|
ui::ChildBox::Init();
|
||||||
|
|
||||||
|
|
||||||
ui::Label* m_label_1 = dynamic_cast<ui::Label*>(FindSubControl(L"uart_info_label"));
|
ui::Label* m_label_1 = dynamic_cast<ui::Label*>(FindSubControl(L"uart_info_label"));
|
||||||
ui::RichEdit* m_rich_edit_1 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_recv_eidt"));
|
ui::RichEdit* m_rich_edit_1 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"uart_recv_eidt"));
|
||||||
ui::RichEdit* m_rich_edit_2 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"lua_script"));
|
ui::RichEdit* m_rich_edit_2 = dynamic_cast<ui::RichEdit*>(FindSubControl(L"lua_script"));
|
||||||
@ -24,7 +22,6 @@ void UdpForm::Init()
|
|||||||
ui::Button* m_button_2 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_close_uart"));
|
ui::Button* m_button_2 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_close_uart"));
|
||||||
ui::Button* m_button_3 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_save_lua"));
|
ui::Button* m_button_3 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_save_lua"));
|
||||||
ui::Button* m_button_4 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_do_lua"));
|
ui::Button* m_button_4 = dynamic_cast<ui::Button*>(FindSubControl(L"btn_do_lua"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaDelegate* UdpForm::LuaVM()
|
LuaDelegate* UdpForm::LuaVM()
|
||||||
@ -34,8 +31,10 @@ LuaDelegate* UdpForm::LuaVM()
|
|||||||
|
|
||||||
void UdpForm::ShowDataInEdit(const char*)
|
void UdpForm::ShowDataInEdit(const char*)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UdpForm::HandleMessage(ui::EventArgs& msg)
|
void UdpForm::HandleMessage(ui::EventArgs& msg)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,11 @@
|
|||||||
class UdpForm :
|
class UdpForm :
|
||||||
public ui::ChildBox
|
public ui::ChildBox
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UdpForm(ui::Window* hwnd, string url, uint32_t port, UdpDataGramLibevent* p);
|
UdpForm(ui::Window* hwnd, string url, uint32_t port, UdpDataGramLibevent* p);
|
||||||
~UdpForm();
|
~UdpForm();
|
||||||
virtual void Init() override;
|
virtual void Init() override;
|
||||||
LuaDelegate* LuaVM();
|
LuaDelegate* LuaVM();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ShowDataInEdit(const char*) ;
|
void ShowDataInEdit(const char*) ;
|
||||||
|
|
||||||
@ -45,7 +43,6 @@ private:
|
|||||||
ui::Button* m_button_3;
|
ui::Button* m_button_3;
|
||||||
ui::Button* m_button_4;
|
ui::Button* m_button_4;
|
||||||
|
|
||||||
|
|
||||||
virtual void HandleMessage(ui::EventArgs& msg);
|
virtual void HandleMessage(ui::EventArgs& msg);
|
||||||
std::string mLuaScript;
|
std::string mLuaScript;
|
||||||
std::string m_url;
|
std::string m_url;
|
||||||
|
3
examples/proto_debuger/udp_group_libevent.cpp
Normal file
3
examples/proto_debuger/udp_group_libevent.cpp
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include "udp_group_libevent.h"
|
||||||
|
|
||||||
|
|
55
examples/proto_debuger/udp_group_libevent.h
Normal file
55
examples/proto_debuger/udp_group_libevent.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#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>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
|
||||||
|
class UdpGroupLibevent {
|
||||||
|
public:
|
||||||
|
typedef std::function<void(const char* dat, int len, struct sockaddr_in)> OnReadDataHandle;
|
||||||
|
UdpGroupLibevent(std::string ip, uint32_t port);
|
||||||
|
OnReadDataHandle* OnReadHandle();
|
||||||
|
typedef enum {
|
||||||
|
RUNNING,
|
||||||
|
STOP,
|
||||||
|
FAIL
|
||||||
|
}STATUS;
|
||||||
|
friend void read_cb(int, short, void*);
|
||||||
|
void SetOnReadHandle(OnReadDataHandle*);
|
||||||
|
void SendTo(const char* dat, uint32_t len, std::string ip, int port);
|
||||||
|
int SocketFD();
|
||||||
|
private:
|
||||||
|
int bind_socket(struct event* ev, const char* ip, uint16_t port);
|
||||||
|
uint32_t m_port; // 监听端口号
|
||||||
|
std::string m_bind_ip; // 绑定端口号
|
||||||
|
uint16_t m_backlog;
|
||||||
|
int m_sock_fd;
|
||||||
|
struct sockaddr_in m_bind_addr; // 绑定地址
|
||||||
|
struct event* m_event;
|
||||||
|
STATUS m_status; //
|
||||||
|
std::thread* m_thread; // 当前线程
|
||||||
|
intptr_t mSocketFD; // 操作系统原生socket
|
||||||
|
OnReadDataHandle* mOnRead;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user