openfl-sockjs icon indicating copy to clipboard operation
openfl-sockjs copied to clipboard

Uncaught ReferenceError: sockjs is not defined

Open johanvdb opened this issue 8 years ago • 1 comments

The HTML5 target for sockjs is failing in the browser console with the error as per the subject of this ticket. It originates from

window._sockjs_js_socket_0.onopen = function() { sockjs.SockJS._sHandleOpen(0) };

Which is generated from line 226 in SockJS.hx

Lib.eval("window._sockjs_js_socket_"+_instanceId+".onopen = function() { sockjs.SockJS._sHandleOpen("+_instanceId+") };");

Reviewing the generated javascript for the entire application, I noticed that the sockjs.SockJS class is obfuscated in the output as sockjs_SockJS (dot notation).

Thus, a change to all the references in the printed Lib.evals to use an underscore actually fixes the problem, but I am not sure if this is the elegant solution.

I will submit a patch, but please review and discuss if it is the correct approach.

johantheitguy$ haxelib list actuate: [1.8.6] box2d: [1.2.3] flixel-addons: [1.1.0] flixel-demos: [1.1.2] flixel-tools: 1.1.0 [1.1.1] flixel: [3.3.11] 3.3.8 hxargs: [3.0.0] hxcpp: [3.2.102] layout: 1.2.0 [1.2.1] lime-samples: 2.3.0 [2.6.0] lime: 2.4.3 2.4.4 2.4.5 [2.6.0] nape: [2.0.19] openfl-bitfive: [3.0.0] openfl-samples: 2.2.2 [3.1.0] openfl: 3.1.0 [3.3.1] sockjs: [1.0.0] swf: 1.8.8 [1.9.1]

johanvdb avatar Sep 07 '15 08:09 johanvdb