MCPcopy Create free account
hub / github.com/cc20110101/RedisView / on__subscribeButton_clicked

Method on__subscribeButton_clicked

src/RedisView/AppView/MainWidget.cpp:1228–1259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1226}
1227
1228void MainWidget::on__subscribeButton_clicked()
1229{
1230 QString chanel = ui->_subPatternLineEdit->text().trimmed();
1231 if(chanel.isEmpty()) {
1232 QMessageBox::about(this, tr("错误"), tr("订阅频道不可为空!"));
1233 return;
1234 }
1235
1236 if(!_redisRecvClient) {
1237 if(_vMasterClients.size() <= 0) {
1238 QMessageBox::about(this, tr("错误"), tr("客户端连接信息为空!"));
1239 return;
1240 } else {
1241 _redisRecvClient = new RedisClient();
1242 _redisRecvClient->open(_vMasterClients[_vMasterClients.size() - 1]._host,
1243 _vMasterClients[_vMasterClients.size() - 1]._port);
1244 if(!_vMasterClients[_vMasterClients.size() - 1]._passwd.isEmpty()) {
1245 if(!_redisRecvClient->auth(_vMasterClients[_vMasterClients.size() - 1]._passwd)) {
1246 QMessageBox::about(this, tr("错误"), _redisRecvClient->getErrorInfo());
1247 return;
1248 }
1249 }
1250 if(!_redisRecvClient->isOpen()) {
1251 QMessageBox::about(this, tr("错误"), tr("客户端连接失败!"));
1252 return;
1253 }
1254 }
1255 _redisRecvClient->setSubModel(true);
1256 connect(_redisRecvClient, &RedisClient::sigMessage, this, &MainWidget::recvMessage);
1257 }
1258 _redisRecvClient->psubscribe(chanel);
1259}
1260
1261void MainWidget::on__unSubcribeButton_clicked()
1262{

Callers

nothing calls this directly

Calls 7

authMethod · 0.80
setSubModelMethod · 0.80
psubscribeMethod · 0.80
textMethod · 0.45
openMethod · 0.45
getErrorInfoMethod · 0.45
isOpenMethod · 0.45

Tested by

no test coverage detected