| 2539 | |
| 2540 | Flashsocket.prototype.ready = function (socket, fn) { |
| 2541 | function init () { |
| 2542 | var options = socket.options |
| 2543 | , port = options['flash policy port'] |
| 2544 | , path = [ |
| 2545 | 'http' + (options.secure ? 's' : '') + ':/' |
| 2546 | , options.host + ':' + options.port |
| 2547 | , options.resource |
| 2548 | , 'static/flashsocket' |
| 2549 | , 'WebSocketMain' + (socket.isXDomain() ? 'Insecure' : '') + '.swf' |
| 2550 | ]; |
| 2551 | |
| 2552 | // Only start downloading the swf file when the checked that this browser |
| 2553 | // actually supports it |
| 2554 | if (!Flashsocket.loaded) { |
| 2555 | if (typeof WEB_SOCKET_SWF_LOCATION === 'undefined') { |
| 2556 | // Set the correct file based on the XDomain settings |
| 2557 | WEB_SOCKET_SWF_LOCATION = path.join('/'); |
| 2558 | } |
| 2559 | |
| 2560 | if (port !== 843) { |
| 2561 | WebSocket.loadFlashPolicyFile('xmlsocket://' + options.host + ':' + port); |
| 2562 | } |
| 2563 | |
| 2564 | WebSocket.__initialize(); |
| 2565 | Flashsocket.loaded = true; |
| 2566 | } |
| 2567 | |
| 2568 | fn.call(self); |
| 2569 | } |
| 2570 | |
| 2571 | var self = this; |
| 2572 | if (document.body) return init(); |