I am writing a client program for the ESP8266 WI-FI module. Data transfer to the server will be done via websocket. For initial debugging you need a websocket server on your local computer. Tried to do with the help of node.js OS Windows7. Put the server using the example below. It works, but on localhost. I need to raise it on the local ip (For example, 192.168.0.103). I did not understand how to change the ip in the code. Please help with this code or there may be some other alternative. Thank you in advance.
var http = require('http'); var Static = require('node-static'); var WebSocketServer = new require('ws'); // подключенные клиенты var clients = {}; var webSocketServer = new WebSocketServer.Server({port: 8081}); webSocketServer.on('connection', function(ws) { var id = Math.random(); clients[id] = ws; console.log("новое соединение " + id); ws.on('message', function(message) { console.log('получено сообщение ' + message); for(var key in clients) { clients[key].send(message); } }); ws.on('close', function() { console.log('соединение закрыто ' + id); delete clients[id]; }); });