@@ -449,38 +449,6 @@ void updateMetricsNames(DriverInfo& driverInfo, std::vector<DeviceMetricsInfo> c
449449 driverInfo.availableMetrics .swap (result);
450450}
451451
452- void processCommand (DeviceInfos& infos,
453- pid_t pid,
454- std::string const & command,
455- std::string const & arg)
456- {
457- auto doToMatchingPid = [](std::vector<DeviceInfo>& infos, int pid, auto lambda) {
458- for (auto & deviceInfo : infos) {
459- if (deviceInfo.pid == pid) {
460- lambda (deviceInfo);
461- break ;
462- }
463- }
464- };
465- LOGP (info, " Found control command {} from pid {} with argument {}." , command, pid, arg);
466- if (command == " QUIT" && arg == " ALL" ) {
467- for (auto & deviceInfo : infos) {
468- deviceInfo.readyToQuit = true ;
469- }
470- } else if (command == " QUIT" && arg == " ME" ) {
471- doToMatchingPid (infos, pid, [](DeviceInfo& info) { info.readyToQuit = true ; });
472- } else if (command == " NOTIFY_STREAMING_STATE" && arg == " IDLE" ) {
473- // FIXME: this should really be a policy...
474- doToMatchingPid (infos, pid, [](DeviceInfo& info) { info.readyToQuit = true ; info.streamingState = StreamingState::Idle; });
475- } else if (command == " NOTIFY_STREAMING_STATE" && arg == " STREAMING" ) {
476- // FIXME: this should really be a policy...
477- doToMatchingPid (infos, pid, [](DeviceInfo& info) { info.streamingState = StreamingState::Streaming; });
478- } else if (command == " NOTIFY_STREAMING_STATE" && arg == " EOS" ) {
479- // FIXME: this should really be a policy...
480- doToMatchingPid (infos, pid, [](DeviceInfo& info) { info.streamingState = StreamingState::EndOfStreaming; });
481- }
482- };
483-
484452// / An handler for a websocket message stream.
485453struct ControlWebSocketHandler : public WebSocketHandler {
486454 ControlWebSocketHandler (DriverServerContext& context)
@@ -528,6 +496,7 @@ struct ControlWebSocketHandler : public WebSocketHandler {
528496 ParsedConfigMatch configMatch;
529497 ParsedMetricMatch metricMatch;
530498
499+ LOG (debug3) << " Data received: " << std::string_view (frame, s);
531500 if (DeviceMetricsHelper::parseMetric (token, metricMatch)) {
532501 // We use this callback to cache which metrics are needed to provide a
533502 // the DataRelayer view.
@@ -536,15 +505,16 @@ struct ControlWebSocketHandler : public WebSocketHandler {
536505 didProcessMetric = true ;
537506 didHaveNewMetric |= hasNewMetric;
538507 } else if (ControlServiceHelpers::parseControl (token, match)) {
539- LOG (debug2 ) << " Found a command, processing for pid " << mPid ;
508+ LOG (error ) << " Found a command, processing for pid " << mPid ;
540509 assert (mContext .infos );
541- processCommand (*mContext .infos , mPid , match[1 ].str (), match[2 ].str ());
510+ ControlServiceHelpers:: processCommand (*mContext .infos , mPid , match[1 ].str (), match[2 ].str ());
542511 } else if (DeviceConfigHelper::parseConfig (std::string{" " } + token, configMatch)) {
543512 LOG (debug2) << " Found configuration information for pid " << mPid ;
544513 assert (mContext .infos );
545514 DeviceConfigHelper::processConfig (configMatch, (*mContext .infos )[mIndex ]);
515+ } else {
516+ LOG (error) << " Unexpected control data: " << std::string_view (frame, s);
546517 }
547- LOG (debug3) << " Data received: " << std::string_view (frame, s);
548518 }
549519
550520 // / FIXME: not implemented
0 commit comments