-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I know who sent a notification? #72
Comments
Unfortunately, no, you can only send some client id with each msg that gets sent from the client after the client was connected with a particular ID. For example: var WebSocket = require('rpc-websockets').Client
var WebSocketServer = require('rpc-websockets').Server
// instantiate Server and start listening for requests
var server = new WebSocketServer({
port: 8080,
host: 'localhost'
})
const conns = {}
server.on('connection', function(s) {
conns[s._id] = s
})
server.register('feedUpdated', function(p) {
console.log('msg rcvd from:', p.socket_id)
})
nr = '12345678'
var ws = new WebSocket('ws://localhost:8080?socket_id=' + nr)
ws.on('open', function() {
ws.notify('feedUpdated', { socket_id: nr })
}) I agree this should be handled internally, optionally. PRs welcome! |
…ferences #72 Signed-off-by: Mario Kozjak <kozjakm1@gmail.com>
@Heniker, please use v5.1.2 for the above workaround. |
@Heniker, this is now available in v5.2.0. Please test the release. You still need to provide var WebSocket = require('rpc-websockets').Client
var WebSocketServer = require('rpc-websockets').Server
// instantiate Server and start listening for requests
var server = new WebSocketServer({
port: 8080,
host: 'localhost'
})
server.register('feedUpdated', function(params, id) {
console.log('msg rcvd from client with id', id) // you will get '12345678' here
})
var ws = new WebSocket('ws://localhost:8080?socket_id=12345678')
ws.on('open', function() {
ws.notify('feedUpdated')
}) |
This looks promising. Thank you for your work! |
In README there is this line -
This is not useful if I can't know which client sent the message.
Is there any way of identifying the client besides using different Namespaces for each connection?
The text was updated successfully, but these errors were encountered: