{"action":"created","issue":{"url":"https://api.github.com/repos/RIAEvangelist/node-ipc/issues/92","repository_url":"https://api.github.com/repos/RIAEvangelist/node-ipc","labels_url":"https://api.github.com/repos/RIAEvangelist/node-ipc/issues/92/labels{/name}","comments_url":"https://api.github.com/repos/RIAEvangelist/node-ipc/issues/92/comments","events_url":"https://api.github.com/repos/RIAEvangelist/node-ipc/issues/92/events","html_url":"https://github.com/RIAEvangelist/node-ipc/issues/92","id":180580904,"number":92,"title":"client identifiers on server","user":{"login":"DutchKev","id":5072775,"avatar_url":"https://avatars.githubusercontent.com/u/5072775?v=3","gravatar_id":"","url":"https://api.github.com/users/DutchKev","html_url":"https://github.com/DutchKev","followers_url":"https://api.github.com/users/DutchKev/followers","following_url":"https://api.github.com/users/DutchKev/following{/other_user}","gists_url":"https://api.github.com/users/DutchKev/gists{/gist_id}","starred_url":"https://api.github.com/users/DutchKev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DutchKev/subscriptions","organizations_url":"https://api.github.com/users/DutchKev/orgs","repos_url":"https://api.github.com/users/DutchKev/repos","events_url":"https://api.github.com/users/DutchKev/events{/privacy}","received_events_url":"https://api.github.com/users/DutchKev/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RIAEvangelist/node-ipc/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-03T07:51:55Z","updated_at":"2016-10-07T01:11:13Z","closed_at":"2016-10-07T01:11:01Z","body":"When using node-ipc to communicate between NodeJS processes over IPC, it seems pretty simple to start a server and listen for connections, or create a client and connect to the server.\r\n\r\nBut there is something that doesn't seem all that simple:\r\n\r\n> *How can the server push a message to a client?*\r\n\r\nThe manual says, \r\n\r\n**On the client, listening to the server for a message**: \r\n\r\n    ipc.connectTo('world', function(){\r\n            ipc.of.world.on('hello', function(data){\r\n                    console.log(data);\r\n                }\r\n            )\r\n        }\r\n    );\r\n\r\nPretty straightforward... But:\r\n\r\n**On the server, sending a message**\r\n\r\n    // Start server\r\n    ipc.serve(function(){\r\n    \r\n        // Listen for connecting clients\r\n        ipc.server.on('connect', socket => {\r\n            // From here I can do ipc.server.emit(socket, 'message', {});\r\n            // But I still do not know the ID of the client that just connected\r\n        });\r\n    });\r\n\r\nSo lets say I setup the server as the given example above, and the client connected.. Than later on in a different timeFrame, On the server side, you would expect this to be the way to send a message to the client:\r\n\r\n    ipc.server.of[TheClientIdThatJustConnected].emit('myMessage')\r\n\r\nBut this does not work, as ipc.server.of is always an empty object and I still do not know the socket client IDs..\r\n\r\nSo the only way I can think of, is to start EVERY process as both a server and a client... Or after the client connected, I send an '_identification' event with a hardcoded ID and store that sockets in a separate object, but that doesn't make any sense, because the socket is already given in the on('connect') function of the ipc.serve()...\r\n\r\nSo, how does a node-ipc server send a message to a connected client?\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/RIAEvangelist/node-ipc/issues/comments/252130148","html_url":"https://github.com/RIAEvangelist/node-ipc/issues/92#issuecomment-252130148","issue_url":"https://api.github.com/repos/RIAEvangelist/node-ipc/issues/92","id":252130148,"user":{"login":"RIAEvangelist","id":369041,"avatar_url":"https://avatars.githubusercontent.com/u/369041?v=3","gravatar_id":"","url":"https://api.github.com/users/RIAEvangelist","html_url":"https://github.com/RIAEvangelist","followers_url":"https://api.github.com/users/RIAEvangelist/followers","following_url":"https://api.github.com/users/RIAEvangelist/following{/other_user}","gists_url":"https://api.github.com/users/RIAEvangelist/gists{/gist_id}","starred_url":"https://api.github.com/users/RIAEvangelist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIAEvangelist/subscriptions","organizations_url":"https://api.github.com/users/RIAEvangelist/orgs","repos_url":"https://api.github.com/users/RIAEvangelist/repos","events_url":"https://api.github.com/users/RIAEvangelist/events{/privacy}","received_events_url":"https://api.github.com/users/RIAEvangelist/received_events","type":"User","site_admin":false},"created_at":"2016-10-07T01:11:13Z","updated_at":"2016-10-07T01:11:13Z","body":"will be in next release."}}
{"actor":{"display_login":"RIAEvangelist"}}