Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created October 20, 2021 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save velotiotech/94dcb281674f48033f6893571f51ac53 to your computer and use it in GitHub Desktop.
Save velotiotech/94dcb281674f48033f6893571f51ac53 to your computer and use it in GitHub Desktop.
ws1.on('open', () => {
console.log('WS1 connected');
let count = 0;
setInterval(() => {
const data = {
type: 'message',
message: `count is ${count}`,
topic: 'general'
}
const message = JSON.stringify(data);
ws1.send(message, (err) => {
if(err) {
console.log(`Error occurred while send data ${err.message}`)
}
console.log(`WS1 OUT ${message}`);
})
count++;
}, 15000)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment