diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-08 16:01:27 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-08 16:04:05 -0800 |
commit | b873dc778f52461129b1e28fb12dd3d4a309851c (patch) | |
tree | e82913bc549a83104ce8abfb518eca6cb6d8aa83 /src/library_sockfs.js | |
parent | 140ea9e81feb09d8f2559995c73d49a39424ef5d (diff) | |
parent | e0268fa1035a718341c53921eee9318d4a8033cd (diff) |
Merge branch 'incoming' into f32
Conflicts:
src/parseTools.js
src/preamble.js
Diffstat (limited to 'src/library_sockfs.js')
-rw-r--r-- | src/library_sockfs.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/library_sockfs.js b/src/library_sockfs.js index af29d11b..bc3aa997 100644 --- a/src/library_sockfs.js +++ b/src/library_sockfs.js @@ -138,7 +138,9 @@ mergeInto(LibraryManager.library, { console.log('connect: ' + url); #endif // the node ws library API is slightly different than the browser's - var opts = ENVIRONMENT_IS_NODE ? {} : ['binary']; + var opts = ENVIRONMENT_IS_NODE ? {headers: {'websocket-protocol': ['binary']}} : ['binary']; + // If node we use the ws library. + var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket']; ws = new WebSocket(url, opts); ws.binaryType = 'arraybuffer'; } catch (e) { @@ -208,7 +210,7 @@ mergeInto(LibraryManager.library, { } }; - var handleMessage = function(data) { + function handleMessage(data) { assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer data = new Uint8Array(data); // make a typed array view on the array buffer @@ -247,7 +249,7 @@ mergeInto(LibraryManager.library, { }); } else { peer.socket.onopen = handleOpen; - peer.socket.onmessage = function(event) { + peer.socket.onmessage = function peer_socket_onmessage(event) { handleMessage(event.data); }; } @@ -573,4 +575,4 @@ mergeInto(LibraryManager.library, { } } } -});
\ No newline at end of file +}); |