I have the following code that queries and listens to comments. Each comment has a page property which stores the comment's page identifier. This identifier is the connection between the comment and its page on the website.
io.socket.on('comment', function(event) {
console.log('event', event)
})
io.socket.get('/comment', {
page: window.PAGE
}, function serverResponded (body, JWR) {
console.log('Sails responded with: ', body)
console.log('with headers: ', JWR.headers)
console.log('and with status code: ', JWR.statusCode)
})
With the code above the browser gets informed about each new comment, even if it does not belong to the current page.
How can I achieve that the browser gets informed about new comments only if the created comment's page equals the current page (which is stored in window.PAGE)? Is it possible with the built-in websocket functionality or do I need to write an extension?