no message
This commit is contained in:
parent
293ed74ed4
commit
4fcdd48a6b
@ -4,6 +4,8 @@
|
||||
#include "utils.h"
|
||||
#include "global.h"
|
||||
#include "websocket_client.h"
|
||||
#include <functional>
|
||||
|
||||
const std::wstring BasicForm::kClassName = L"Basic";
|
||||
|
||||
BasicForm::BasicForm():
|
||||
@ -212,6 +214,13 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
WebsocketClient* client = (WebsocketClient*)lParam;
|
||||
auto form = new WebsocketClientForm(this, wstring2string(info->ip),client);
|
||||
client->SetOnConnectedHandler(std::bind(&WebsocketClientForm::OnConnected,
|
||||
form, std::placeholders::_1));
|
||||
client->SetOnDisConnectedHandler(std::bind(&WebsocketClientForm::OnDisConnected,
|
||||
form, std::placeholders::_1, std::placeholders::_2));
|
||||
client->SetOnReadHandler(std::bind(&WebsocketClientForm::OnReadHandler,
|
||||
form, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
form->SetChildLayoutXML(L"basic/tcp_server_form.xml");
|
||||
form->SetName(key);
|
||||
form->SetVisible(false);
|
||||
|
@ -81,9 +81,9 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<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>
|
||||
<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>
|
||||
<ReferencePath>$(ReferencePath)</ReferencePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(ProjectDir)third\lib;E:\conan_data\OPENSSL\1.1.1\_\_\build\0ec50343443903d4bfcd42b174a43ee3f59cc16e\pkgsrc</LibraryPath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(ProjectDir)third\lib;I:\home\.conan\data\OPENSSL\1.1.1\_\_\build\149ed843ea788702da310f9d8f34c34c2a72994a\pkgsrc\out32dll</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
@ -132,7 +132,7 @@
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<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;libcrypto_static.lib;libssl_static.lib;Bcrypt.lib;libcmtd.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;ssleay32.lib;libeay32.lib;Bcrypt.lib;libcmtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@ -212,6 +212,7 @@
|
||||
<Xml Include="..\x64\Debug\resources\themes\default\basic\tcp_form.xml" />
|
||||
<Xml Include="..\x64\Debug\resources\themes\default\basic\tcp_server_form.xml" />
|
||||
<Xml Include="..\x64\Debug\resources\themes\default\basic\udp_form.xml" />
|
||||
<Xml Include="..\x64\Debug\resources\themes\default\basic\websocket_client_form.xml" />
|
||||
<Xml Include="x64\Debug\themes\default\global.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -12,6 +12,7 @@ WebsocketClientForm::WebsocketClientForm(ui::Window* hwnd, string url, Websocket
|
||||
|
||||
WebsocketClientForm::~WebsocketClientForm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WebsocketClientForm::Init()
|
||||
@ -29,8 +30,7 @@ void WebsocketClientForm::Init()
|
||||
m_btn_close_form = dynamic_cast<ui::Button*>(FindSubControl(L"btn_close_uart"));
|
||||
|
||||
if (nullptr != m_label_1) {
|
||||
if (mWebsocketClient->State() == WebsocketClient::CONNECTED)
|
||||
{
|
||||
if (mWebsocketClient->State() == WebsocketClient::CONNECTED) {
|
||||
m_label_1->SetText(std::wstring() + L"服务端: " +
|
||||
string2wstring(mWebsocketClient->Url()) + L"连接成功");
|
||||
}
|
||||
@ -73,3 +73,27 @@ void WebsocketClientForm::ShowDataInEdit(const char*src)
|
||||
{
|
||||
m_rich_edit_1->AppendText(string2wstring(std::string(src)),false);
|
||||
}
|
||||
|
||||
void WebsocketClientForm::OnConnected(WebsocketClient* ws)
|
||||
{
|
||||
if (nullptr != m_label_1) {
|
||||
if (mWebsocketClient->State() == WebsocketClient::CONNECTED) {
|
||||
m_label_1->SetText(std::wstring() + L"服务端: " +
|
||||
string2wstring(mWebsocketClient->Url()) + L"连接成功");
|
||||
}
|
||||
else {
|
||||
m_label_1->SetText(std::wstring() + L"服务端: " +
|
||||
string2wstring(mWebsocketClient->Url()) + L"连接失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebsocketClientForm::OnDisConnected(WebsocketClient* ws, WebsocketClient::CloseReason)
|
||||
{
|
||||
std::cout << "OnDisConnected" << std::endl;
|
||||
}
|
||||
|
||||
void WebsocketClientForm::OnReadHandler(WebsocketClient* ws, std::string message)
|
||||
{
|
||||
std::cout << "recv data from hanlder" << message.c_str();
|
||||
}
|
||||
|
@ -26,6 +26,9 @@ public:
|
||||
virtual void Init() override;
|
||||
LuaDelegate* LuaVM();
|
||||
void ShowDataInEdit(const char*);
|
||||
void OnConnected(WebsocketClient*);
|
||||
void OnDisConnected(WebsocketClient*, WebsocketClient::CloseReason);
|
||||
void OnReadHandler(WebsocketClient*, std::string);
|
||||
private:
|
||||
ui::Label* m_label_1;
|
||||
ui::RichEdit* m_rich_edit_1;
|
||||
|
Loading…
Reference in New Issue
Block a user