KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Two related questions that may be more rooted in my lack of knowledge of how/if browsers pre-parse javascript: var ws = new WebSocket("ws://ws.my.url.com"); ws.onOpen = function() { ... }; There appears to be no way to directly control the initialisation of a WebSocket , beyond wrapping it in a callback, so I assume the connection is created as soon as the javascript code is loaded and get to the constructor? When does the onOpen property get attached to ws ? Is there any possibility of a race condition (if for some reason you had some code in between the definition of the socket and the definition of onOpen ?) so that onOpen is undecidably bound before/after the connection is established (I know you could optionally check ws.readyState ). Supplementary to this, is the WebSocket handshake blocking? I realise it's all a draft at the moment, possibly implementation dependent and I may have missed something blindingly obvious, but I couldn't see anything particular pertinent on my internet searches/skim through the draft w3c spec, so any help in my understanding of websockets/javascript's inner workings is very much appreciated!
Tags (comma-separated)
Save Edits
Cancel