mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Add comms.stop to tidy up keepalive timer
This commit is contained in:
parent
6c464ed3a4
commit
8e8e13a3a2
@ -82,6 +82,11 @@ function start() {
|
||||
}, webSocketKeepAliveTime);
|
||||
}
|
||||
|
||||
function stop() {
|
||||
clearInterval(heartbeatTimer);
|
||||
wsServer.close();
|
||||
}
|
||||
|
||||
function publish(topic,data,retain) {
|
||||
if (retain) {
|
||||
retained[topic] = data;
|
||||
@ -116,5 +121,6 @@ function handleRemoteSubscription(ws,topic) {
|
||||
module.exports = {
|
||||
init:init,
|
||||
start:start,
|
||||
stop:stop,
|
||||
publish:publish,
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ function start() {
|
||||
|
||||
function stop() {
|
||||
redNodes.stopFlows();
|
||||
comms.stop();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -25,6 +25,7 @@ var address = '127.0.0.1';
|
||||
var listenPort = 0; // use ephemeral port
|
||||
|
||||
describe("comms", function() {
|
||||
describe("with default keepalive", function() {
|
||||
var server;
|
||||
var url;
|
||||
var port;
|
||||
@ -40,6 +41,10 @@ describe("comms", function() {
|
||||
});
|
||||
});
|
||||
|
||||
after(function() {
|
||||
comms.stop();
|
||||
});
|
||||
|
||||
it('accepts connection', function(done) {
|
||||
var ws = new WebSocket(url);
|
||||
ws.on('open', function() {
|
||||
@ -123,8 +128,12 @@ describe("comms", function() {
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
describe("keep alives", function() {
|
||||
var server;
|
||||
var url;
|
||||
var port;
|
||||
before(function(done) {
|
||||
server = http.createServer(function(req,res){app(req,res)});
|
||||
comms.init(server, {webSocketKeepAliveTime: 100});
|
||||
@ -136,6 +145,9 @@ describe("comms", function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
after(function() {
|
||||
comms.stop();
|
||||
});
|
||||
it('are sent', function(done) {
|
||||
var ws = new WebSocket(url);
|
||||
var count = 0;
|
||||
|
@ -277,6 +277,9 @@ describe('Node', function() {
|
||||
});
|
||||
|
||||
describe('#status', function() {
|
||||
after(function() {
|
||||
comms.publish.restore();
|
||||
});
|
||||
it('publishes status', function(done) {
|
||||
var n = new RedNode({id:'123',type:'abc'});
|
||||
var status = {fill:"green",shape:"dot",text:"connected"};
|
||||
|
Loading…
Reference in New Issue
Block a user