当前位置: 首页 > news >正文

网站有哪些功能如何制作餐馆网站

网站有哪些功能,如何制作餐馆网站,长沙市建设厅官方网站,seo需要掌握哪些技术到官网下载qssh的源码QSsh-botan-1#xff0c;使用qtcreator打开后#xff0c;直接编译#xff0c;即可得到qssh的库 头文件将QSsh-botan-1\src\libs\ssh目录下的.h文件拷到include文件夹下#xff0c;即为库头文件。 qssh有个问题#xff0c;如果你将qssh的类放在子线程…到官网下载qssh的源码QSsh-botan-1使用qtcreator打开后直接编译即可得到qssh的库 头文件将QSsh-botan-1\src\libs\ssh目录下的.h文件拷到include文件夹下即为库头文件。 qssh有个问题如果你将qssh的类放在子线程中调用将获取不到服务器发送回来的数据。故只能放在主线程调用。如有需要从子线程调用的话可通过在子线程发送信号来调用主线程的槽从而调用到qssh的功能使得qssh在主线程调用即能正常使用。 封装如下 // .h #ifndef SSHCLIENT_H #define SSHCLIENT_H #include qobject.h #include sshconnection.h #include sshremoteprocess.hclass SshClient : public QObject {Q_OBJECT public:SshClient();~SshClient();void ConnectToHost(const QString host, const QString user, const QString pwd);void DisConnectFromHost();void SendCmd(const QByteArray data);signals:void SendDataRecv(const QByteArray data);void SendConnected(bool bConned);void SendShellStarted(bool bStarted);void SendRetMsg(const QString msg);private slots:void OnConnected();void onConnectionError(QSsh::SshError);void OnShellStarted();void OnShellDataRecieved();void OnShellError();private:QString mIp;QString mUserName;QString mPwd;QSsh::SshConnection *mpConnection Q_NULLPTR; // 连接ssh服务器QSharedPointerQSsh::SshRemoteProcess mpShell; // ssh的shell用于发送与回显消息 };#endif // SSHCLIENT_H// .cpp #include qcoreapplication.h #include sshclient.h #include log.hSshClient::SshClient() {}SshClient::~SshClient() {DisConnectFromHost(); }void SshClient::ConnectToHost(const QString host, const QString username, const QString pwd) {QSsh::SshConnectionParameters params;params.setHost(host);params.setUserName(username);params.setPassword(pwd);params.authenticationType QSsh::SshConnectionParameters::AuthenticationTypePassword;params.timeout 10;//30;params.setPort(22);if(mpConnection Q_NULLPTR){mpConnection new QSsh::SshConnection(params, this); // TODO free this pointer!}connect(mpConnection, SIGNAL(connected()), SLOT(OnConnected()));connect(mpConnection, SIGNAL(error(QSsh::SshError)), SLOT(onConnectionError(QSsh::SshError)));mpConnection-disconnectFromHost();mpConnection-connectToHost();LOG_INFO(conneting to host:%s user:%s pwd:%s,qPrintable(host),qPrintable(username),qPrintable(pwd)); }void SshClient::DisConnectFromHost() {if(mpShell){emit SendShellStarted(false);mpShell-close();mpShell.reset();}if(mpConnection ! Q_NULLPTR){emit SendConnected(false);mpConnection-disconnectFromHost();delete mpConnection;mpConnection Q_NULLPTR;} }void SshClient::OnConnected() {emit SendConnected(true);LOG_INFO(ssh is connected);mpShell mpConnection-createRemoteShell();connect(mpShell.get(), SIGNAL(started()), SLOT(OnShellStarted()));connect(mpShell.get(), SIGNAL(readyReadStandardOutput()), SLOT(OnShellDataRecieved()));connect(mpShell.get(), SIGNAL(readyReadStandardError()), SLOT(OnShellError()));mpShell-start(); }void SshClient::onConnectionError(QSsh::SshError) {QString errStr mpConnection-errorString();emit SendRetMsg(QString::fromLocal8Bit(连接出错:%1).arg(errStr));LOG_ERROR(ssh connected err:%s,mpConnection-errorString().toLocal8Bit().data());//mpConnection-disconnectFromHost();// mpConnection-connectToHost(); }void SshClient::OnShellStarted() {LOG_INFO(shell is started);SendShellStarted(true); }void SshClient::OnShellDataRecieved() {QByteArray data mpShell-readAll();if (data.isEmpty())return;emit SendDataRecv(data);LOG_DEBUG(recv from shell data:%s,data.data()); }void SshClient::OnShellError() {emit SendRetMsg(QString::fromLocal8Bit(错误:%1).arg(mpShell-errorString()));LOG_ERROR(recv from shell err:%s,mpShell-errorString().toLocal8Bit().data()); }// 发送了命令后shell会回复两条同样的命令用于回显 void SshClient::SendCmd(const QByteArray data) {if(!mpShell){LOG_ERROR(shell is not start, cant sendmsg:%s,data.data());return;}qint64 n mpShell-write(data);LOG_DEBUG(write shell data, len:%d, data:%s,n,data.data());static const int timeoutMs 3000;int index 0;bool bsucc mpShell-waitForReadyRead(10);while(!bsucc index timeoutMs){ index 10;QCoreApplication::processEvents();if (!mpShell) break;bsucc mpShell-waitForReadyRead(10);} /*if (bsucc){QByteArray data mpShell-readAll();if (data.isEmpty())return;emit SendDataRecv(data);LOG_DEBUG(recv from shell data:%s, data.data());}*/ }
http://www.sadfv.cn/news/366883/

相关文章:

  • 哪个公司做视频网站东莞品牌网站设计
  • 做网站的案例定制网站建设多少钱
  • 查询网站备案号如何修改一个网站的后台登陆系统
  • 化工外贸网站建设新媒体运营师证书
  • 漳州企业网站建设制作dedecms 调用 两个网站
  • 互联网公司网站建设ppt模板下载网站建设推进会讲话稿
  • 朝阳专业做网站网页制作代码简单
  • 上海住房城乡建设网站证件查询深圳做网站的网络公司
  • 建设网站方法有哪些内容服务好的专业建站公司
  • 网站建设公司长沙广东做陶瓷的网站
  • 网站建设需求列表滁州百度seo
  • 旅游电子商务网站网站开发要什么
  • 成都哪个公司做网站wordpress案例制作
  • html手机网站模板下载小程序是什么时候出来的
  • 个人网站设计作品展示中国新闻社是国企还是私企
  • 有关网页设计与网站建设的文章临沂网站制作价格
  • 专业做网站安全的sine安不用代码做网站
  • 企业做网站建设的好处网站规划教学设计
  • 合肥网站排名优化公司有什么网站帮做邀请函设计的
  • 收到一张网站服务费怎么做凭证免费无版权图片素材网站
  • 健康资讯网源码 养生保健网站源码(织梦dedecms5.7做网站开发要注册
  • 商城网站静态模板下载广州网站建设腾虎
  • 网站建设哪个好一些做网站要的软件
  • 岳阳网站平台设计懒人手机网站
  • 南宁电商网站建设用DW给网站做后台
  • 网络网站制作技巧域名跳转
  • 接网站建设外包的工作低价网站建设教程
  • 网站建设策划书编制1g做网站空间
  • 江苏省住房与城乡建设部网站开发商延期交房怎么处理
  • asp.net 网站 方案制作流程图的网站