diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-06 11:50:49 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-06 11:50:49 -0800 |
commit | 663075274d30ae406734e7eb5ef8b07c9340e9a6 (patch) | |
tree | 18206b36b421b1a2f099284f8b619237ff15cc22 /src/library_sockfs.js | |
parent | c0f26e65da33a6437a04d1adba19966f98fd79cb (diff) | |
parent | b1a0b6eddf91ff1c1fc85081273c6c8325541113 (diff) |
Merge pull request #1743 from fadams/fix-nodejs-socket-client
add support for node.js to act as a socket client
Diffstat (limited to 'src/library_sockfs.js')
-rw-r--r-- | src/library_sockfs.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/library_sockfs.js b/src/library_sockfs.js index a57a51a1..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) { @@ -573,4 +575,4 @@ mergeInto(LibraryManager.library, { } } } -});
\ No newline at end of file +}); |