提交 4137a4c1 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Test cluster phyzical connection

上级 c01f7be1
...@@ -26,7 +26,8 @@ SOURCES += main.cpp\ ...@@ -26,7 +26,8 @@ SOURCES += main.cpp\
smartlink/st_clientnode_basetrans.cpp \ smartlink/st_clientnode_basetrans.cpp \
smartlink/st_clientnode_app_imp.cpp \ smartlink/st_clientnode_app_imp.cpp \
smartlink/st_clientnode_applayer.cpp \ smartlink/st_clientnode_applayer.cpp \
cluster/zp_clusterterm.cpp cluster/zp_clusterterm.cpp \
dialogaddressinput.cpp
HEADERS += zpmainframe.h \ HEADERS += zpmainframe.h \
network/zp_tcpserver.h \ network/zp_tcpserver.h \
...@@ -42,9 +43,12 @@ HEADERS += zpmainframe.h \ ...@@ -42,9 +43,12 @@ HEADERS += zpmainframe.h \
smartlink/st_msg_applayer.h \ smartlink/st_msg_applayer.h \
smartlink/st_clientnode_basetrans.h \ smartlink/st_clientnode_basetrans.h \
smartlink/st_clientnode_applayer.h \ smartlink/st_clientnode_applayer.h \
cluster/zp_clusterterm.h cluster/zp_clusterterm.h \
cluster/cross_svr_messages.h \
dialogaddressinput.h
FORMS += zpmainframe.ui FORMS += zpmainframe.ui \
dialogaddressinput.ui
RESOURCES += \ RESOURCES += \
resource.qrc resource.qrc
......
#ifndef CROSS_SVR_MESSAGES_H
#define CROSS_SVR_MESSAGES_H
namespace ZP_Cluster{
#pragma pack (push,1)
#if defined(__GNUC__)
#include <stdint.h>
typedef struct tag_cross_svr_message{
struct tag_header{
__UINT16_TYPE__ Mark; //Always be "0x1234"
__UINT8_TYPE__ messagetype;
} hearder;
union uni_payload{
struct tag_plainData{
__UINT16_TYPE__ data_length;
__UINT8_TYPE__ data[1];
} plainData;
} payload;
} CROSS_SVR_MSG;
#endif
#if defined(_MSC_VER)
typedef struct tag_cross_svr_message{
struct tag_header{
unsigned __int16 Mark; //Always be 0x1234
unsigned __int8 messagetype;
} hearder;
union uni_payload{
struct tag_plainData{
unsigned __int16 data_length;
unsigned __int8 data[1];
} plainData;
} payload;
} CROSS_SVR_MSG;
#endif
}
#endif // CROSS_SVR_MESSAGES_H
...@@ -6,6 +6,7 @@ namespace ZP_Cluster{ ...@@ -6,6 +6,7 @@ namespace ZP_Cluster{
{ {
m_pClusterEng = new ZPTaskEngine::zp_pipeline(this); m_pClusterEng = new ZPTaskEngine::zp_pipeline(this);
m_pClusterNet = new ZPNetwork::zp_net_ThreadPool(8192,this); m_pClusterNet = new ZPNetwork::zp_net_ThreadPool(8192,this);
m_nPortPublish = 0;
} }
void zp_ClusterTerm::StartListen(const QHostAddress &addr, int nPort) void zp_ClusterTerm::StartListen(const QHostAddress &addr, int nPort)
...@@ -13,9 +14,9 @@ namespace ZP_Cluster{ ...@@ -13,9 +14,9 @@ namespace ZP_Cluster{
m_pClusterNet->AddListeningAddress(m_strTermName,addr,nPort,false); m_pClusterNet->AddListeningAddress(m_strTermName,addr,nPort,false);
} }
bool zp_ClusterTerm::JoinCluster(const QHostAddress &addr, int nPort) bool zp_ClusterTerm::JoinCluster(const QHostAddress &addr, int nPort,bool bSSL)
{ {
return m_pClusterNet->connectTo(addr,nPort); return m_pClusterNet->connectTo(addr,nPort,bSSL);
} }
bool zp_ClusterTerm::canExit() bool zp_ClusterTerm::canExit()
{ {
......
...@@ -41,7 +41,7 @@ namespace ZP_Cluster{ ...@@ -41,7 +41,7 @@ namespace ZP_Cluster{
//!Join cluster, using existing term (addr:nPort) //!Join cluster, using existing term (addr:nPort)
//!as soon as connection established, more existing terms will be sent to this term, //!as soon as connection established, more existing terms will be sent to this term,
//!an p2p connection will start //!an p2p connection will start
bool JoinCluster(const QHostAddress &addr, int nPort); bool JoinCluster(const QHostAddress &addr, int nPort,bool bSSL=false);
}; };
} }
......
#include "dialogaddressinput.h"
#include "ui_dialogaddressinput.h"
DialogAddressInput::DialogAddressInput(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogAddressInput)
{
ui->setupUi(this);
}
DialogAddressInput::~DialogAddressInput()
{
delete ui;
}
void DialogAddressInput::SetAddr(QString addr, QString port)
{
ui->lineEdit_addr->setText(addr);
ui->lineEdit_port->setText(port);
}
QString DialogAddressInput::addr()
{
return ui->lineEdit_addr->text();
}
QString DialogAddressInput::port()
{
return ui->lineEdit_port->text();
}
#ifndef DIALOGADDRESSINPUT_H
#define DIALOGADDRESSINPUT_H
#include <QDialog>
namespace Ui {
class DialogAddressInput;
}
class DialogAddressInput : public QDialog
{
Q_OBJECT
public:
explicit DialogAddressInput(QWidget *parent = 0);
~DialogAddressInput();
void SetAddr(QString addr, QString port);
QString addr();
QString port();
private:
Ui::DialogAddressInput *ui;
};
#endif // DIALOGADDRESSINPUT_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogAddressInput</class>
<widget class="QDialog" name="DialogAddressInput">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>174</width>
<height>97</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Addr</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_addr"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_port"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogAddressInput</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogAddressInput</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
...@@ -11,6 +11,8 @@ namespace ZPNetwork{ ...@@ -11,6 +11,8 @@ namespace ZPNetwork{
qRegisterMetaType<qintptr>("qintptr"); qRegisterMetaType<qintptr>("qintptr");
if (false==QMetaType::isRegistered(QMetaType::type("QAbstractSocket::SocketError"))) if (false==QMetaType::isRegistered(QMetaType::type("QAbstractSocket::SocketError")))
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError"); qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
if (false==QMetaType::isRegistered(QMetaType::type("QHostAddress")))
qRegisterMetaType<QHostAddress>("QHostAddress");
} }
QStringList zp_net_ThreadPool::ListenerNames() QStringList zp_net_ThreadPool::ListenerNames()
......
...@@ -123,6 +123,9 @@ namespace ZPNetwork{ ...@@ -123,6 +123,9 @@ namespace ZPNetwork{
connect(sock_client, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)),Qt::QueuedConnection); connect(sock_client, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)),Qt::QueuedConnection);
connect(sock_client, &QTcpSocket::bytesWritten, this,&zp_netTransThread::some_data_sended,Qt::QueuedConnection); connect(sock_client, &QTcpSocket::bytesWritten, this,&zp_netTransThread::some_data_sended,Qt::QueuedConnection);
connect(sock_client, &QTcpSocket::connected,this, &zp_netTransThread::on_encrypted,Qt::QueuedConnection); connect(sock_client, &QTcpSocket::connected,this, &zp_netTransThread::on_encrypted,Qt::QueuedConnection);
m_mutex_protect.lock();
m_clientList[sock_client] = 0;
m_mutex_protect.unlock();
sock_client->connectToHost(addr,port); sock_client->connectToHost(addr,port);
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QSqlDatabase> #include <QSqlDatabase>
#include <QMap> #include <QMap>
#include "dialogaddressinput.h"
using namespace ZPNetwork; using namespace ZPNetwork;
using namespace ZPTaskEngine; using namespace ZPTaskEngine;
using namespace ZP_Cluster; using namespace ZP_Cluster;
...@@ -685,3 +686,18 @@ void ZPMainFrame::on_pushButton_db_apply_clicked() ...@@ -685,3 +686,18 @@ void ZPMainFrame::on_pushButton_db_apply_clicked()
{ {
SaveSettings(m_currentConffile); SaveSettings(m_currentConffile);
} }
void ZPMainFrame::on_pushButton_join_clicked()
{
QSettings settings(this->m_currentConffile,QSettings::IniFormat);
QString strAddr = settings.value("history/clusterAddr","192.168.1.118").toString();
QString strPort = settings.value("history/clusterPort","25600").toString();
DialogAddressInput inputdlg(this);
inputdlg.SetAddr(strAddr,strPort);
if (inputdlg.exec()==QDialog::Accepted)
{
settings.setValue("history/clusterAddr",inputdlg.addr());
settings.setValue("history/clusterPort",inputdlg.port());
m_pClusterTerm->JoinCluster(QHostAddress(inputdlg.addr()),inputdlg.port().toInt());
}
}
...@@ -72,6 +72,7 @@ public slots: ...@@ -72,6 +72,7 @@ public slots:
void on_pushButton_cluster_apply_clicked(); void on_pushButton_cluster_apply_clicked();
void on_pushButton_smartlink_save_clicked(); void on_pushButton_smartlink_save_clicked();
void on_pushButton_join_clicked();
}; };
......
...@@ -13,6 +13,24 @@ ...@@ -13,6 +13,24 @@
<property name="windowTitle"> <property name="windowTitle">
<string>ZPMainFrame</string> <string>ZPMainFrame</string>
</property> </property>
<property name="toolTipDuration">
<number>-1</number>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
<property name="animated">
<bool>true</bool>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
...@@ -890,6 +908,15 @@ ...@@ -890,6 +908,15 @@
<addaction name="menu_Help"/> <addaction name="menu_Help"/>
</widget> </widget>
<widget class="QToolBar" name="mainToolBar"> <widget class="QToolBar" name="mainToolBar">
<property name="movable">
<bool>true</bool>
</property>
<property name="allowedAreas">
<set>Qt::AllToolBarAreas</set>
</property>
<property name="floatable">
<bool>false</bool>
</property>
<attribute name="toolBarArea"> <attribute name="toolBarArea">
<enum>TopToolBarArea</enum> <enum>TopToolBarArea</enum>
</attribute> </attribute>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册