gAmUssA
69p25 comments posted · 1 followers · following 2
12 years ago @ ...all we are is dust ... - WebSockets for Java De... · 2 replies · +1 points
As you mentioned earlier, new Websocket(ws://host); is async. With async model event would be fired by framework and you as developer just define handlers. In vanilla JavaScript, you should not rely on ready state for your case and manually check connection state.
According to spec, when connection is established open event will be fired. You can define handle onopen handler.
websocket.onopen = function (event) {
console.log('open');
};
Java code from your example is gwt, isn't it?
Thanks
--
With Best Regards,
Vik Gamov
<p style="color:#a0a0a8">
12 years ago @ ...all we are is dust ... - WebSockets for Java De... · 0 replies · +1 points
The simplest way is to put your websocket object to global scope. For obvious reasons, this approach is not very good. What you're looking for is to incapsulate websocket instance as singleton. e.g. you can read here how to do that here
http://addyosmani.com/resources/essentialjsdesignpatterns/book/#singletonpatternjavascript
Thanks
--
With Best Regards,
Vik Gamov
<p style="color: #A0A0A8;">
12 years ago @ ...all we are is dust ... - Мобильное и ... · 0 replies · +1 points
13 years ago @ Mac OS World .RU - Полное руко... · 0 replies · +1 points
13 years ago @ ...all we are is dust ... - Поскорее бы ... · 0 replies · +1 points
13 years ago @ Радио-Т - Темы для 219 · 0 replies · +26 points
14 years ago @ Радио-Т - Темы для 218 · 0 replies · +3 points
14 years ago @ Радио-Т - Темы для 217 · 0 replies · +3 points
14 years ago @ Радио-Т - Темы для 192 · 0 replies · -6 points
14 years ago @ Русский блог - Portable IE6 · 0 replies · +1 points