| 502 | } |
| 503 | |
| 504 | void GrApplication::StartSpvrClientIfNeeded() { |
| 505 | auto appkey = GetAppkey(); |
| 506 | auto spvr_host = settings_->GetSpvrServerHost(); |
| 507 | auto spvr_port = settings_->GetSpvrServerPort(); |
| 508 | auto device_id = settings_->GetDeviceId(); |
| 509 | if (appkey.empty() || spvr_host.empty() || spvr_port <= 0 || device_id.empty()) { |
| 510 | return; |
| 511 | } |
| 512 | |
| 513 | if (appkey != using_appkey_) { |
| 514 | LOGW("Appkey changed, {} => {} will release WS:SpvrClient and recreate it.", using_appkey_, appkey); |
| 515 | if (spvr_client_) { |
| 516 | spvr_client_->Stop(); |
| 517 | spvr_client_ = nullptr; |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | if (!spvr_client_) { |
| 522 | spvr_client_ = std::make_shared<GrSpvrClient>(context_, spvr_host, spvr_port, device_id); |
| 523 | } |
| 524 | if (!spvr_client_->IsStarted()) { |
| 525 | spvr_client_->Start(); |
| 526 | } |
| 527 | using_appkey_ = appkey; |
| 528 | } |
| 529 | |
| 530 | std::shared_ptr<SpvrScanner> GrApplication::GetSpvrScanner() { |
| 531 | return spvr_scanner_; |
no test coverage detected