I'm trying Angularjs with sockjs and I'm using this to help: https://github.com/bendrucker/angular-sockjs
I would like to send some data via sockjs on page load but I'm getting Error: INVALID_STATE_ERR on the client side when I try to make the following call:
socket.send("test data");
I assume this is because Sockjs isn't "ready" yet. If I wrap it in a $timeout it works if the delay is big enough. 1000 works but 100 doesn't.
$timeout(function() {
socket.send("test");
}, 1000);
This is obviously a hack and I wondered how I can detect when sockjs is ready so that I can then make the call.