no message

master
zcy 2021-09-13 00:27:40 +08:00
parent d29d688b55
commit 15084716e8
4 changed files with 10 additions and 2 deletions

View File

@ -112,6 +112,7 @@ int QmlShareData::openNetwork(QString ip, unsigned int port, bool is_ws,int type
m_tcp_server->moveToThread(this->thread());
connect(m_tcp_server,SIGNAL(on_onnected(string , uint )),this,SLOT(on_network_conected(string , uint )),Qt::DirectConnection);
connect(m_tcp_server,SIGNAL(on_disconected(string , uint )),this,SLOT(on_network_disconected(string , uint )),Qt::DirectConnection);
connect(m_tcp_server,SIGNAL(on_conn_read(string )),this,SLOT(on_network_server_read(string)),Qt::DirectConnection);
return 0;
}
@ -226,6 +227,11 @@ void QmlShareData::on_udp_data_recv(){
}
}
void QmlShareData::on_network_server_read(string ip)
{
qDebug()<<ip.c_str();
}

View File

@ -59,6 +59,7 @@ public slots:
void on_network_conected(string,uint);
void on_network_disconected(string,uint);
void on_udp_data_recv();
void on_network_server_read(string);
private:
TcpServerLibevent *m_tcp_server;

View File

@ -113,7 +113,8 @@ void read_cb(struct bufferevent *bev, void *arg)
char buf[1024] = {0};
ConnectionLibevent* conn = (ConnectionLibevent*)arg;
bufferevent_read(bev, buf, sizeof(buf));
auto server = conn->Server();
emit(server->on_conn_read("12345"));
cout << "client " << conn->IpAddress() << " say:" << buf << endl;
conn->OnRecv(buf,sizeof(buf));
}
@ -359,5 +360,4 @@ TcpServerLibevent::~TcpServerLibevent(){
delete m_event_listener;
m_event_listener = nullptr;
}
}

View File

@ -115,6 +115,7 @@ public:
signals:
int on_onnected(string ip,uint sock);
int on_disconected(string ip,uint sock);
int on_conn_read(string ip);
#endif
private: