{"action":"created","issue":{"url":"https://api.github.com/repos/thoov/mock-socket/issues/13","labels_url":"https://api.github.com/repos/thoov/mock-socket/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/thoov/mock-socket/issues/13/comments","events_url":"https://api.github.com/repos/thoov/mock-socket/issues/13/events","html_url":"https://github.com/thoov/mock-socket/issues/13","id":58481445,"number":13,"title":"Sockets send messages multiple times","user":{"login":"Ghirigoro","id":406106,"avatar_url":"https://avatars.githubusercontent.com/u/406106?v=3","gravatar_id":"","url":"https://api.github.com/users/Ghirigoro","html_url":"https://github.com/Ghirigoro","followers_url":"https://api.github.com/users/Ghirigoro/followers","following_url":"https://api.github.com/users/Ghirigoro/following{/other_user}","gists_url":"https://api.github.com/users/Ghirigoro/gists{/gist_id}","starred_url":"https://api.github.com/users/Ghirigoro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ghirigoro/subscriptions","organizations_url":"https://api.github.com/users/Ghirigoro/orgs","repos_url":"https://api.github.com/users/Ghirigoro/repos","events_url":"https://api.github.com/users/Ghirigoro/events{/privacy}","received_events_url":"https://api.github.com/users/Ghirigoro/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-22T00:05:05Z","updated_at":"2015-02-24T06:34:46Z","closed_at":null,"body":"I'm running into a problem while testing in Node. The server seems to receive more messages than are sent. It gets as many copies of a message as there are sockets connected. So if you have 3 sockets connected the server will receive 3 copies of every message. Below is a Mocha test case I wrote to find the issue in case it helps. \r\n\r\ndescribe('MockSocket', function() {\r\n\t\tit ('server should only receive as many messages as are sent', function(done) {\r\n\r\n\t\t\tvar url = 'ws://localhost:8080';\r\n\r\n\t\t\tvar server = new MockServer(url);\r\n\r\n\t\t\tvar num_messages_sent = 0;\r\n\t\t\tvar num_messages_received = 0;\r\n\r\n\t\t\tserver.on('connection', function (socket) {\r\n\t\t\t\tsocket.on('message', function (event) {\r\n\t\t\t\t\tconsole.log(\"RECEIVED: \" + event.data);\r\n\t\t\t\t\tnum_messages_received++;\r\n\t\t\t\t});\r\n\t\t\t});\r\n\r\n\t\t\tvar s1 = new MockSocket(url);\r\n\t\t\ts1.onopen = function () {\r\n\t\t\t\tnum_messages_sent++;\r\n\t\t\t\ts1.send(\"1\");\r\n\t\t\t};\r\n\r\n\t\t\tvar s2 = new MockSocket(url);\r\n\t\t\ts2.onopen = function () {\r\n\t\t\t\tnum_messages_sent++;\r\n\t\t\t\ts2.send(\"2\");\r\n\t\t\t};\r\n\r\n\t\t\tsetInterval(function () {\r\n\t\t\t\tassert.equal(num_messages_received, num_messages_sent);\r\n                                done();\r\n\t\t\t}, 500);\r\n\t\t}\r\n\t});\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/thoov/mock-socket/issues/comments/75706867","html_url":"https://github.com/thoov/mock-socket/issues/13#issuecomment-75706867","issue_url":"https://api.github.com/repos/thoov/mock-socket/issues/13","id":75706867,"user":{"login":"thoov","id":166909,"avatar_url":"https://avatars.githubusercontent.com/u/166909?v=3","gravatar_id":"","url":"https://api.github.com/users/thoov","html_url":"https://github.com/thoov","followers_url":"https://api.github.com/users/thoov/followers","following_url":"https://api.github.com/users/thoov/following{/other_user}","gists_url":"https://api.github.com/users/thoov/gists{/gist_id}","starred_url":"https://api.github.com/users/thoov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoov/subscriptions","organizations_url":"https://api.github.com/users/thoov/orgs","repos_url":"https://api.github.com/users/thoov/repos","events_url":"https://api.github.com/users/thoov/events{/privacy}","received_events_url":"https://api.github.com/users/thoov/received_events","type":"User","site_admin":false},"created_at":"2015-02-24T06:34:46Z","updated_at":"2015-02-24T06:34:46Z","body":"@Ghirigoro Thanks for the issue. Let me take a look at it tomorrow and see if I can come up with a fix."}}