This commit is contained in:
2015-06-12 09:05:18 +02:00
parent 0a63e3752c
commit 0399674af7
35 changed files with 77 additions and 19 deletions
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
@@ -1,25 +1,33 @@
define([
"dojo/_base/config",
'dojo/_base/declare',
'dstore/Rest',
'dstore/RequestMemory',
'dstore/SimpleQuery',
'dstore/Trackable',
'dstore/Tree',
'dojo/_base/lang',
'dstore/Store',
'dojo/request',
'dstore/QueryResults',
'dstore/Cache',
"hos/Socket",
"dojo/request/xhr",
"dojox/uuid/generateRandomUuid"
], function(config, declare, Rest, RequestMemory, SimpleQuery, Trackable, Tree, Socket, xhr, generateRandomUuid){
], function(config, declare, lang, Store, request, QueryResults, Cache, Socket, xhr, generateRandomUuid){
var RuleEngineStore = declare([Rest, RequestMemory, SimpleQuery, Trackable, Tree], {
_getTarget: function(id){
var target = this.target;
if(!target.slice(-1) == '/'){
target += "/";
}
return target + "packages" + id;
var _RuleEngineStore = declare([Store], {
_request: function (target, options) {
// Most responses will be in JSON, so we make that the default expected format.
options = lang.mixin({ handleAs: 'json' }, options);
options.headers = lang.mixin({}, this.headers, options.headers);
return request(this.target + target, options);
},
fetch: function () {
return new QueryResults(this._request('packages'));
}
});
var RuleEngineStore = declare([_RuleEngineStore, Cache], {
isValidFetchCache: true
});
var _store = new RuleEngineStore({
target: config.hos.ruleEngineUrl
View File
View File
View File
View File
View File
View File
View File
View File
View File
+24 -3
View File
@@ -41,10 +41,31 @@
"dojo/on",
"dojo/domReady!"
], function(RuleEngine, domConstruct, dom, on){
var test1 = RuleEngine.get("rulepkg01");
//var test1 = RuleEngine.get("rulepkg01");
var test1 = RuleEngine.fetch().then(function(results){
console.log("results1: ", results);
});
console.log("test1: ", test1);
var test2 = RuleEngine.filter({arg01: "param01"});
console.log("test2: ", test2);
var f1 = RuleEngine.filter();
var c1 = f1.fetch();
c1.then(function(data) {
console.log("data: ", data);
RuleEngine.emit('update', {id: data.id, target: data});
});
f1.on('update', function(data) {
console.log("update");
});
RuleEngine.filter().fetch().then(function(data) {
console.log("data1: ", data);
});
RuleEngine.filter().fetch().then(function(data) {
console.log("data2: ", data);
});
RuleEngine.filter().fetch().then(function(data) {
console.log("data3: ", data);
});
//var test2 = RuleEngine.filter({arg01: "param01"});
//console.log("test2: ", test2);
});
</script>
@@ -102,6 +102,9 @@
console.log("Update: ", update);
}
);
_devices.filter().on('update', function(event){
console.log("Observe2 triggered: ", event);
});
_devices.on('update', function(event){
// this will be called any time a market is added, removed, or updated
console.log("Observe triggered: ", event);
@@ -97,6 +97,8 @@ void WebServerServiceImpl::init() noexcept {
webServerParams->setSoftwareVersion("Home Operating System alpha");
webServerParams->setMaxThreads(10);
ErrorHandler::set(&errorHandler);
try {
Net::ServerSocket webServerSocket(8080);
webServer.reset(new Poco::Net::HTTPServer(&handlerFactory, webServerSocket, webServerParams));
@@ -235,6 +237,21 @@ bool WebServerServiceImpl::checkAuthentication( const Poco::Net::HTTPServerReque
}
void WebServerServiceImpl::ErrorHandler::exception(const Poco::Exception& exc) {
ROS_ERROR_STREAM("Webserver caught exception (" << exc.code() << "): " << exc.displayText());
}
void WebServerServiceImpl::ErrorHandler::exception(const std::exception& exc) {
ROS_ERROR_STREAM("Webserver caught exception: " << exc.what());
}
void WebServerServiceImpl::ErrorHandler::exception() {
ROS_ERROR_STREAM("Webserver caught unknown exception.");
}
} // namespace webserver
} // namespace service
} // namespace cosgi
@@ -15,9 +15,6 @@
#include <vector>
#include <iostream>
#include <Poco/Net/HTTPServer.h>
#include <Poco/Net/HTTPRequestHandlerFactory.h>
#include <Poco/Net/HTTPRequestHandler.h>
@@ -26,6 +23,7 @@
#include <Poco/URI.h>
#include <Poco/Net/SecureServerSocket.h>
#include <Poco/Net/SSLManager.h>
#include <Poco/ErrorHandler.h>
@@ -39,12 +37,23 @@ namespace webserver {
class WebServerServiceImpl
: public virtual WebServerService,
public implementation::Service<WebServerServiceImpl> {
private:
class ErrorHandler
: public Poco::ErrorHandler {
public:
virtual void exception(const Poco::Exception& exc);
virtual void exception(const std::exception& exc);
virtual void exception();
} errorHandler;
class RequestHandlerFactory
: public Poco::Net::HTTPRequestHandlerFactory {
private: