no message
This commit is contained in:
parent
3a3887a763
commit
293ed74ed4
@ -198,6 +198,7 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
});
|
||||
mMonitorNewSelect->Close();
|
||||
}
|
||||
|
||||
if (uMsg == WM_ADD_WEBSOCKET_CLIENT) {
|
||||
TcpServerInfo* info = (TcpServerInfo*)wParam;
|
||||
ui::TreeNode* node = new ui::TreeNode;
|
||||
@ -279,7 +280,6 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (p != nullptr) {
|
||||
printf("GetCurSel %d\r\n", mRightSide->GetCurSel());
|
||||
|
||||
p->SetAutoDestroy(true);
|
||||
if (mRightShow != nullptr) {
|
||||
mRightShow->SetVisible(false);
|
||||
|
@ -211,7 +211,7 @@ void NewMonitorForm::InitWindow()
|
||||
if (m_combo_type->GetText() == L"websocket client") {
|
||||
wprintf(L"%s\r\n", m_ip_select->GetText().c_str());
|
||||
wprintf(L"%s\r\n", m_port_select->GetText().c_str());
|
||||
WebsocketClient* wsclient = new WebsocketClient(wstring2string(m_ip_select->GetText().c_str()),false);
|
||||
WebsocketClient* wsclient = new WebsocketClient(wstring2string(m_ip_select->GetText().c_str()),true);
|
||||
|
||||
TcpServerInfo* p = new TcpServerInfo;
|
||||
p->ip = m_ip_select->GetText();
|
||||
|
@ -98,6 +98,10 @@ WebsocketClient::~WebsocketClient() {
|
||||
m_thread->join();
|
||||
}
|
||||
|
||||
std::string WebsocketClient::Url()
|
||||
{
|
||||
return this->m_url;
|
||||
}
|
||||
WebsocketClient::WebsocketClient(std::string url, bool tls)
|
||||
{
|
||||
m_tls = tls;
|
||||
@ -140,9 +144,9 @@ WebsocketClient::WebsocketClient(std::string url, bool tls)
|
||||
if (ec) {
|
||||
std::cout << "could not create connection because: " << ec.message() << std::endl;
|
||||
this->m_status = Status::FAIL;
|
||||
break;
|
||||
}
|
||||
std::cout << "2" << std::endl;
|
||||
|
||||
// Note that connect here only requests a connection. No network messages are
|
||||
// exchanged until the event loop starts running in the next line.
|
||||
TlsClient::connection_ptr ptr = m_client_tls.connect(m_conn_tls);
|
||||
@ -158,9 +162,7 @@ WebsocketClient::WebsocketClient(std::string url, bool tls)
|
||||
&& (this->m_status != WebsocketClient::STOP)
|
||||
) {
|
||||
try {
|
||||
// while(this->m_status == WebsocketClient::CONNECTED){
|
||||
int count_of_handler = this->m_client_tls.run();
|
||||
// std::cout<<"count_of_handler: " << count_of_handler<<std::endl;
|
||||
// }
|
||||
// run应该只执行一次就会退出
|
||||
}
|
||||
@ -210,10 +212,10 @@ WebsocketClient::WebsocketClient(std::string url, bool tls)
|
||||
std::cout << "could not create connection because: " << ec.message() << std::endl;
|
||||
this->m_status = Status::FAIL;
|
||||
if (m_on_disconnected)
|
||||
m_on_disconnected(this, WebsocketClient::CloseReason::LOCAL_CLOSED);
|
||||
m_on_disconnected(this,
|
||||
WebsocketClient::CloseReason::LOCAL_CLOSED);
|
||||
break;
|
||||
}
|
||||
std::cout << "2" << std::endl;
|
||||
|
||||
// Note that connect here only requests a connection. No network messages are
|
||||
// exchanged until the event loop starts running in the next line.
|
||||
@ -228,7 +230,8 @@ WebsocketClient::WebsocketClient(std::string url, bool tls)
|
||||
while ((this->m_status != WebsocketClient::FAIL) &&
|
||||
(this->m_status != WebsocketClient::CLOSED)
|
||||
&& (this->m_status != WebsocketClient::STOP)
|
||||
) {
|
||||
)
|
||||
{
|
||||
try {
|
||||
// while(this->m_status == WebsocketClient::CONNECTED){
|
||||
int count_of_handler = this->m_client.run();
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
Status State(){
|
||||
return m_status;
|
||||
}
|
||||
std::string Url();
|
||||
WebsocketClient(std::string url,bool tls);
|
||||
~WebsocketClient();
|
||||
int SendMsg(const char * str,uint32_t len,websocketpp::frame::opcode::value);
|
||||
|
@ -17,7 +17,7 @@ WebsocketClientForm::~WebsocketClientForm()
|
||||
void WebsocketClientForm::Init()
|
||||
{
|
||||
ui::ChildBox::Init();
|
||||
m_label_1 = dynamic_cast<ui::Label*>(FindSubControl(L"uart_info_label"));
|
||||
m_label_1 = dynamic_cast<ui::Label*>(FindSubControl(L"server_info"));
|
||||
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"));
|
||||
@ -28,9 +28,22 @@ void WebsocketClientForm::Init()
|
||||
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"));
|
||||
|
||||
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"连接失败");
|
||||
}
|
||||
}
|
||||
if (nullptr != m_btn_close_form)
|
||||
m_btn_close_form->AttachClick([this](const ui::EventArgs* ev) {
|
||||
|
||||
wstring* name = new wstring(this->GetName());
|
||||
::PostMessage(this->GetWindow()->GetHWND(),
|
||||
WM_ADD_WEBSOCKET_CLIENT_CLOSE, (WPARAM)name, 0);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
@ -42,6 +55,7 @@ void WebsocketClientForm::Init()
|
||||
return true;
|
||||
}
|
||||
);
|
||||
|
||||
if (nullptr != m_btn_send_data) {
|
||||
m_btn_send_data->AttachClick([this](const ui::EventArgs* ev) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user