Ejemplo n.º 1
0
        bool call(const std::string & name_, arguments & args_, std::string & result_, bool threaded) {
            if (_methods.find(name_) == _methods.end()) {
                // @TODO: Exceptions
                return false;
            }
            if (threaded) {
                std::lock_guard<std::mutex> lock(_messages_lock);
                _messages.push(dispatch_message(name_, args_, _message_id));
                
                // @TODO: We should provide an interface for this serialization.
                std::stringstream ss;
                ss << "[\"result_id\", " << _message_id << "]";
                result_ = ss.str();

                _message_id = _message_id + 1;
            } else {
#ifdef _DEBUG
                if (name_ != "fetch_result") {
                    LOG(TRACE) << "dispatch[immediate]:\t[" << name_ << "] { " << args_.get() << " }";
                }
#endif
                return dispatcher::call(name_, args_, result_);
            }

            return true;
        }
Ejemplo n.º 2
0
        bool call(const arguments & args_, std::string & result) {
            //LOG(INFO) << "Calling [" << args_.as_string(0) << "]";

            if (_modules.find(args_.as_string(0)) == _modules.end()) {
                return false;
            }

            result = "";
            result.resize(4096);

            std::string function_str;
            std::vector<std::string> temp = ace::split(args_.get(), ',');

            if (temp.size() < 3) {
                function_str = temp[1];
            } else {
                for (int x = 1; x < temp.size(); x++)
                    function_str = function_str + temp[x] + ",";
            }
            _modules[args_.as_string(0)].function((char *)result.c_str(), 4096, (const char *)function_str.c_str());
#ifdef _DEBUG
            //if (args_.as_string(0) != "fetch_result" && args_.as_string(0) != "ready") {
            //    LOG(INFO) << "Called [" << args_.as_string(0) << "], with {" << function_str << "} result={" << result << "}";
            //}
#endif
            return true;
        }