From b43c9838a5760d9a6f32049798cb292a7876ec3c Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Wed, 19 Jan 2011 13:01:28 -0600 Subject: [PATCH] web-socket-js: Add function invocation fix. Related to this issue: https://github.com/gimite/web-socket-js/issues/#issue/50 This prevents the "Uncaught exception: TypeError: 'this.__handleEvents' is not a function" everytime the timer fires. Yay, one of Javascript's worst behaviors; the way it sets "this". --- include/web-socket-js/web_socket.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/web-socket-js/web_socket.js b/include/web-socket-js/web_socket.js index 2a7da35c..48ec0fcb 100755 --- a/include/web-socket-js/web_socket.js +++ b/include/web-socket-js/web_socket.js @@ -165,8 +165,9 @@ if (this.__timer) clearInterval(this.__timer); if (window.opera) { // Workaround for weird behavior of Opera which sometimes drops events. + var that = this; this.__timer = setInterval(function () { - this.__handleEvents(); + that.__handleEvents(); }, 500); } if (this.onopen) this.onopen();