no message
This commit is contained in:
parent
ae82225d07
commit
a08bf0ccd4
@ -104,12 +104,11 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
mRightShow->SetVisible(false);
|
||||
p->SetVisible(true);
|
||||
mRightShow = p;
|
||||
wprintf(L"%s",p->GetName());
|
||||
mRightSide->SelectItem(p->GetName());
|
||||
|
||||
}
|
||||
else {
|
||||
p->SetVisible(true);
|
||||
|
||||
mRightSide->SelectItem(p->GetName());
|
||||
mRightShow = p;
|
||||
}
|
||||
|
@ -55,51 +55,6 @@ void LuaDelegate::OnSerialData(std::string data){
|
||||
lua_call(mVM,1,0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
// 这部分代码可以写成一个统一的c++ 调用lua的接口,核心在于
|
||||
// lua_getglobal这个函数调用,其他的参数可以通过回调函数传入,不排除RTTI等技术使用
|
||||
// </summary>
|
||||
// <param name="addr"></param>
|
||||
// <param name="data"></param>
|
||||
// <param name="port"></param>
|
||||
void LuaDelegate::OnNetworkData(char *addr, char *data, uint32_t port)
|
||||
{
|
||||
std::cout<<"call lua network callback";
|
||||
int ret = lua_getglobal(mVM,"OnNetworkData");
|
||||
if(ret == 0)
|
||||
return;
|
||||
std::cout<<ret;
|
||||
lua_pushstring(mVM,addr);
|
||||
lua_pushstring(mVM,data);
|
||||
lua_pushnumber(mVM,port);
|
||||
lua_call(mVM,3,0);
|
||||
}
|
||||
|
||||
void LuaDelegate::OnNewTcpClient(std::string ip, uint32_t port, uint32_t sockptr)
|
||||
{
|
||||
std::cout<<"call lua network new client callback";
|
||||
int ret = lua_getglobal(mVM,"OnNewClient");
|
||||
if(ret == 0)
|
||||
return;
|
||||
std::cout<<ret;
|
||||
lua_pushstring(mVM,ip.c_str());
|
||||
lua_pushinteger(mVM,port);
|
||||
lua_pushinteger(mVM,sockptr);
|
||||
lua_call(mVM,3,0);
|
||||
}
|
||||
|
||||
void LuaDelegate::OnClientLeave(std::string ip, uint32_t port, uint32_t sockptr)
|
||||
{
|
||||
std::cout<<"call lua network leave callback";
|
||||
int ret = lua_getglobal(mVM,"OnClientLeave");
|
||||
if(ret == 0)
|
||||
return;
|
||||
std::cout<<ret;
|
||||
lua_pushstring(mVM,ip.c_str());
|
||||
lua_pushnumber(mVM,port);
|
||||
lua_pushnumber(mVM,sockptr);
|
||||
lua_call(mVM,3,0);
|
||||
}
|
||||
|
||||
|
||||
void LuaDelegate::DumpStack()
|
||||
|
@ -16,21 +16,75 @@ extern "C" {
|
||||
}
|
||||
|
||||
|
||||
class LuaDelegate{
|
||||
class LuaDelegate {
|
||||
public:
|
||||
LuaDelegate();
|
||||
LuaDelegate(std::map<std::string, lua_CFunction>);
|
||||
LuaDelegate(std::map<std::string, lua_CFunction>);
|
||||
|
||||
int DoFile(std::string);
|
||||
void Stop();
|
||||
int DoString(std::string);
|
||||
int UpdateScript(std::string);
|
||||
|
||||
template <typename T,typename ... Types>
|
||||
void pushstack(T arg1,Types... rest) {
|
||||
const std::type_info &t1 = typeid(arg1);
|
||||
pushstack(rest...);
|
||||
template <typename T>
|
||||
void pushstack(T arg1);
|
||||
void pushstack(lua_Number arg) {
|
||||
lua_pushnumber(mVM, arg);
|
||||
}
|
||||
void pushstack(lua_Integer arg) {
|
||||
lua_pushinteger(mVM, arg);
|
||||
}
|
||||
void pushstack(void* arg) {
|
||||
lua_pushlightuserdata(mVM, arg);
|
||||
}
|
||||
void pushstack(const char* arg) {
|
||||
lua_pushstring(mVM,arg);
|
||||
}
|
||||
void pushstack(bool arg) {
|
||||
lua_pushboolean (mVM, arg);
|
||||
}
|
||||
void pushstack(std::string arg) {
|
||||
lua_pushstring(mVM, arg.c_str());
|
||||
}
|
||||
void pushstack(lua_CFunction fn, int n) {
|
||||
lua_pushcclosure(mVM, fn, n);
|
||||
}
|
||||
template <typename T, typename ... Types>
|
||||
void pushstack(T arg1, Types... rest);
|
||||
template <typename ... Types>
|
||||
void pushstack(lua_Number arg1, Types... rest) {
|
||||
lua_pushnumber(mVM, arg1);
|
||||
pushstack(rest...);
|
||||
}
|
||||
template <typename ... Types>
|
||||
void pushstack(lua_Integer arg1, Types... rest) {
|
||||
lua_pushinteger (mVM, arg1);
|
||||
pushstack(rest...);
|
||||
}
|
||||
template <typename ... Types>
|
||||
void pushstack(bool arg1, Types... rest) {
|
||||
lua_pushboolean(mVM, arg1);
|
||||
pushstack(rest...);
|
||||
}
|
||||
template <typename ... Types>
|
||||
void pushstack(std::string arg1, Types... rest) {
|
||||
lua_pushstring(mVM, arg1.c_str());
|
||||
pushstack(rest...);
|
||||
}
|
||||
template <typename ... Types>
|
||||
void pushstack(void* arg1, Types... rest) {
|
||||
lua_pushlightuserdata(mVM, arg1);
|
||||
pushstack(rest...);
|
||||
}
|
||||
template <typename ... Types>
|
||||
void pushstack(lua_CFunction fn, int n, Types... rest) {
|
||||
lua_pushcclosure(mVM, fn,n);
|
||||
pushstack(rest...);
|
||||
}
|
||||
template <typename ... Types>
|
||||
void pushstack(const char* arg1, Types... rest) {
|
||||
lua_pushstring(mVM, arg1);
|
||||
pushstack(rest...);
|
||||
}
|
||||
template<typename... T>
|
||||
void CallFuntion(std::string name,T... para){
|
||||
int i = lua_getglobal(mVM,name.c_str());
|
||||
@ -39,6 +93,7 @@ public:
|
||||
}
|
||||
pushstack(para...);
|
||||
}
|
||||
|
||||
void PrintError(lua_State *L);
|
||||
|
||||
void OnSerialData(std::string);
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "base_form.h"
|
||||
#include"resource1.h"
|
||||
#include <math.h>
|
||||
#include "lua_wraper.h"
|
||||
|
||||
|
||||
enum ThreadId
|
||||
{
|
||||
@ -47,6 +49,11 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
AllocConsole();
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
|
||||
LuaDelegate lua;
|
||||
std::cout << std::endl;
|
||||
|
||||
lua.CallFuntion< lua_Number>(std::string("sds"),
|
||||
123.0);
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "tcp_client_form.h"
|
||||
#include "utils.h"
|
||||
|
||||
TcpClientForm::TcpClientForm(ui::Window* hwnd,std::string url, uint32_t port, TcpClientLibevent* p)
|
||||
{
|
||||
@ -6,6 +7,9 @@ TcpClientForm::TcpClientForm(ui::Window* hwnd,std::string url, uint32_t port, Tc
|
||||
if (nullptr != hwnd) {
|
||||
this->SetWindow(hwnd, nullptr, false);
|
||||
}
|
||||
m_url = url;
|
||||
m_port = port;
|
||||
|
||||
}
|
||||
|
||||
void TcpClientForm::Init()
|
||||
@ -22,6 +26,11 @@ void TcpClientForm::Init()
|
||||
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"));
|
||||
|
||||
|
||||
wchar_t p[100] = { 0 };
|
||||
wsprintf(p, L"華硊%s,傷諳瘍%d ", string2wstring(m_url).c_str(),m_port);
|
||||
m_label_1->SetText(std::wstring(p));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,4 +36,7 @@ private:
|
||||
|
||||
virtual void HandleMessage(ui::EventArgs& msg);
|
||||
|
||||
std::string m_url;
|
||||
int m_port;
|
||||
|
||||
};
|
Loading…
Reference in New Issue
Block a user