void ServerMethods::subscribe (const Json::Value ¶ms, Json::Value &response) { std::shared_ptr<MediaObject> obj; std::string eventType; std::string handlerId; std::string sessionId; std::string objectId; requireParams (params); JsonRpc::getValue (params, "type", eventType); JsonRpc::getValue (params, OBJECT, objectId); try { JsonRpc::getValue (params, SESSION_ID, sessionId); } catch (JsonRpc::CallException e) { generateUUID (sessionId); } try { obj = MediaSet::getMediaSet().getMediaObject (sessionId, objectId); handlerId = connectEventHandler (obj, sessionId, eventType, params); if (handlerId == "") { throw KurentoException (MEDIA_OBJECT_EVENT_NOT_SUPPORTED, "Event not found"); } } catch (KurentoException &ex) { Json::Value data; data["code"] = ex.getCode(); data["message"] = ex.getMessage(); JsonRpc::CallException e (JsonRpc::ErrorCode::SERVER_ERROR_INIT, ex.what(), data); throw e; } response["sessionId"] = sessionId; response["value"] = handlerId; }
void Recognizer::connectEventHandler(const std::function<void(const std::vector<std::string>&)>& eventCb) { connectEventHandler( EventHandlerRef( new EventHandlerSegment( eventCb ) ) ); }
void Recognizer::connectEventHandler(const std::function<void(const std::vector<std::pair<std::string,float> >&)>& eventCb) { connectEventHandler( EventHandlerRef( new EventHandlerSegmentConfidence( eventCb ) ) ); }
void Recognizer::connectEventHandler(const std::function<void(const std::string&)>& eventCb) { connectEventHandler( EventHandlerRef( new EventHandlerBasic( eventCb ) ) ); }