You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To send the sensory data to the p2p network in WebSocket, use the URI ws://[ip_address:port]/object/[name]/send in which you must specify the IP address, port and user-defined object name. For example, there is one peer node running at the address 192.168.1.2:8001 within the p2p network.
ws://192.168.1.2:8001/object/frontdoor/send
The following example periodically sends simulated temperature data to the wot server.
var WebSocketClient = require('websocket').client;
var client = new WebSocketClient();
client.on('connectFailed', function(error) {
console.log('Connect Error: ' + error.toString());
});
client.on('connect', function(connection) {
console.log('WebSocket client connected');
connection.on('error', function(error) {
console.log("Connection Error: " + error.toString());
});
connection.on('close', function() {
console.log('echo-protocol Connection Closed');
});
function sendNumber() {
if (connection.connected) {
var number = Math.round(Math.random() * 0xFFFFFF);
var lucky = Math.round(Math.random() * 100 + 1);
var obj = {temperature: lucky};
console.log('[SEND]', JSON.stringify(obj));
connection.sendUTF(JSON.stringify(obj));
setTimeout(sendNumber, 1000);
}
}
sendNumber();
});
client.connect('ws://192.168.1.2:8001/object/frontdoor/send', '');
Hi every one
I face this problem that show to me is run but the localhost for coap and websocket when i was paste on the browser was not work
-14ISK:~/devify-server$ node websocket-broker-server.js && node coap-broker-server.js
WoT/WebSocket server is listening at ws://localhost:8000
The text was updated successfully, but these errors were encountered: