{"action":"created","issue":{"url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/935","labels_url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/935/labels{/name}","comments_url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/935/comments","events_url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/935/events","html_url":"https://github.com/BrowserSync/browser-sync/issues/935","id":122831045,"number":935,"title":"Sending event from browser to server","user":{"login":"stoffeastrom","id":682243,"avatar_url":"https://avatars.githubusercontent.com/u/682243?v=3","gravatar_id":"","url":"https://api.github.com/users/stoffeastrom","html_url":"https://github.com/stoffeastrom","followers_url":"https://api.github.com/users/stoffeastrom/followers","following_url":"https://api.github.com/users/stoffeastrom/following{/other_user}","gists_url":"https://api.github.com/users/stoffeastrom/gists{/gist_id}","starred_url":"https://api.github.com/users/stoffeastrom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stoffeastrom/subscriptions","organizations_url":"https://api.github.com/users/stoffeastrom/orgs","repos_url":"https://api.github.com/users/stoffeastrom/repos","events_url":"https://api.github.com/users/stoffeastrom/events{/privacy}","received_events_url":"https://api.github.com/users/stoffeastrom/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-17T21:55:29Z","updated_at":"2015-12-19T20:32:21Z","closed_at":"2015-12-19T20:32:21Z","body":"Tried using the `window.___browserSync___.socket.emit(\"foo\");` but I don't get notified on the server using\r\n\r\n`instance.io.sockets.on(\"foo\", () => { console.log(\"foo\"); } );`\r\n\r\nI'm using browser sync to run mocha tests in the browser and would like to tell the server when it's finished.\r\n\r\nAny pointers?"},"comment":{"url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/comments/166021989","html_url":"https://github.com/BrowserSync/browser-sync/issues/935#issuecomment-166021989","issue_url":"https://api.github.com/repos/BrowserSync/browser-sync/issues/935","id":166021989,"user":{"login":"shakyShane","id":1643522,"avatar_url":"https://avatars.githubusercontent.com/u/1643522?v=3","gravatar_id":"","url":"https://api.github.com/users/shakyShane","html_url":"https://github.com/shakyShane","followers_url":"https://api.github.com/users/shakyShane/followers","following_url":"https://api.github.com/users/shakyShane/following{/other_user}","gists_url":"https://api.github.com/users/shakyShane/gists{/gist_id}","starred_url":"https://api.github.com/users/shakyShane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shakyShane/subscriptions","organizations_url":"https://api.github.com/users/shakyShane/orgs","repos_url":"https://api.github.com/users/shakyShane/repos","events_url":"https://api.github.com/users/shakyShane/events{/privacy}","received_events_url":"https://api.github.com/users/shakyShane/received_events","type":"User","site_admin":false},"created_at":"2015-12-19T20:32:21Z","updated_at":"2015-12-19T20:32:21Z","body":"yep, you just need to wait until Browsersync is ready before you listen for connections\r\n\r\n```js\r\nvar browserSync = require('./').create();\r\n\r\nbrowserSync\r\n    .init({\r\n        minify: false,\r\n        server: 'test/fixtures'\r\n    }, listen);\r\n\r\nfunction listen() {\r\n    browserSync.sockets.on('connection', function (client) {\r\n        client.on('foo', function () {\r\n            console.log('ere');\r\n        });\r\n    });\r\n}\r\n```\r\n\r\nthen on the client you can \r\n\r\n```js\r\nwindow.___browserSync___.socket.emit(\"foo\");\r\n```"}}