diff --git a/components/net/cpp/src/dispatcher.cpp b/components/net/cpp/src/dispatcher.cpp index 34b01238accbe92e5b32c74171b429506a201552..ec5781d6af3e69b795b7a53952c9ae70c72bbd92 100644 --- a/components/net/cpp/src/dispatcher.cpp +++ b/components/net/cpp/src/dispatcher.cpp @@ -65,15 +65,15 @@ void ftl::net::Dispatcher::dispatch_call(Peer &s, const msgpack::object &msg) { // assert(type == 0); if (type == 1) { - DLOG(INFO) << "RPC return for " << id; + LOG(INFO) << "RPC return for " << id; s._dispatchResponse(id, args); } else if (type == 0) { - DLOG(INFO) << "RPC " << name << "() <- " << s.getURI(); + LOG(INFO) << "RPC " << name << "() <- " << s.getURI(); auto func = _locateHandler(name); if (func) { - DLOG(INFO) << "Found binding for " << name; + LOG(INFO) << "Found binding for " << name; try { auto result = (*func)(args); //->get(); s._sendResponse(id, result->get()); diff --git a/components/net/cpp/src/peer.cpp b/components/net/cpp/src/peer.cpp index 6738470fe013e533d769a1cb3c860537a0cfa4ff..67d68ae52f7ef631dea5f652752fee9feaf1c944 100644 --- a/components/net/cpp/src/peer.cpp +++ b/components/net/cpp/src/peer.cpp @@ -489,9 +489,13 @@ bool Peer::_data() { UNIQUE_LOCK(recv_mtx_,lk); - if (scheme_ == ftl::URI::SCHEME_WS && !ws_read_header_) { + if (scheme_ == ftl::URI::SCHEME_WS) { + LOG(INFO) << "Reading WS Header"; wsheader_type ws; + ws.header_size = 0; if (ws_parse(recv_buf_, ws) < 0) { + LOG(ERROR) << "Bad WS header " << ws.header_size; + is_waiting_ = true; return false; } ws_read_header_ = true; @@ -571,6 +575,7 @@ void Peer::cancelCall(int id) { } void Peer::_sendResponse(uint32_t id, const msgpack::object &res) { + LOG(INFO) << "Sending response: " << id; Dispatcher::response_t res_obj = std::make_tuple(1,id,std::string(""),res); UNIQUE_LOCK(send_mtx_,lk); if (scheme_ == ftl::URI::SCHEME_WS) send_buf_.append_ref(nullptr,0); diff --git a/web-service/src/index.js b/web-service/src/index.js index f4096ecdcb17b32510a3baa6e74245771a49e02f..e10a54ab9dfe22c248ac6fb115b4d42f04e43acf 100644 --- a/web-service/src/index.js +++ b/web-service/src/index.js @@ -139,7 +139,7 @@ app.ws('/', (ws, req) => { let p = new Peer(ws); p.on("connect", (peer) => { - console.log("Node connected..."); + console.log("Node connected...", peer.string_id); peer_uris[peer.string_id] = []; peer_by_id[peer.string_id] = peer; @@ -150,6 +150,7 @@ app.ws('/', (ws, req) => { peer.name = obj.title; peer.master = (obj.kind == "master"); console.log("Peer name = ", peer.name); + console.log("Details: ", details); checkStreams(peer); }); @@ -175,6 +176,10 @@ app.ws('/', (ws, req) => { checkStreams(p); }); + p.bind("node_details", () => { + return ['{"title": "FTL Web-Service", "id": "0", "kind": "master"}']; + }); + p.bind("list_streams", () => { return Object.keys(uri_data); }); @@ -189,10 +194,10 @@ app.ws('/', (ws, req) => { } }); - p.proxy("source_calibration", (cb, uri) => { + p.proxy("source_details", (cb, uri) => { let peer = uri_data[uri].peer; if (peer) { - peer.rpc("source_calibration", cb, uri); + peer.rpc("source_details", cb, uri); } }); diff --git a/web-service/src/peer.js b/web-service/src/peer.js index b1fc40dd8e6f7198a5857fcaec92d08bc9628307..ab8987f2c8bdd002fbdde08e97ae9dff0fd7fa59 100644 --- a/web-service/src/peer.js +++ b/web-service/src/peer.js @@ -90,11 +90,12 @@ Peer.prototype._dispatchNotification = function(name, args) { Peer.prototype._dispatchCall = function(name, id, args) { if (this.bindings.hasOwnProperty(name)) { console.log("Call for:", name, id); - let res = this.bindings[name].apply(this, args); try { + let res = this.bindings[name].apply(this, args); this.sock.send(encode([1,id,name,res])); } catch(e) { + console.error("Could to dispatch or return call"); this.close(); } } else if (this.proxies.hasOwnProperty(name)) {