I want to run a javascript program without terminating inside node.js :---
Is it the right way to do it by using while(1);
?
Inside this javascript program i have created a websocket & listing to it.
Whenever data comes on websocket it throws on console.log.
test.js :--
var tt = new websocket_fun();
function websocket_fun()
{
var temp = new websocket_create();
while(1);
}
function websocket_create()
{
// Open the socket
this.socket = new WebSocket( "192.168.0.11:8080");
// Bind events
this.socket.onmessage = this.onMessagesocket.bind(this);
this.socket.onopen = this.onOpensocket.bind(this);
this.socket.onclose = this.onClosesocket.bind(this);
}
websocket_create.prototype.onMessagesocket = function(msg)
{
console.log(msg);
}
websocket_create.prototype.onOpensocket = function(msg)
{
console.log('Open websocket');
}
websocket_create.prototype.onClosesocket = function(msg)
{
console.log('Close websocket');
}
run :---
node test.js