diff options
author | Fraser Adams <fraser.adams@blueyonder.co.uk> | 2013-10-27 20:30:13 +0000 |
---|---|---|
committer | Fraser Adams <fraser.adams@blueyonder.co.uk> | 2013-10-27 20:30:13 +0000 |
commit | 7a902d9e4d79e370f44f94a9a7f7ed45ba3dfbb2 (patch) | |
tree | ad4d6721e331bdaf5ecfc8e77052014743f163d1 /src/library_sockfs.js | |
parent | 14c6628d28648cd069a9e0e519cc69513e3d470b (diff) |
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 af29d11b..0e083bfd 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. + WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : WebSocket; ws = new WebSocket(url, opts); ws.binaryType = 'arraybuffer'; } catch (e) { @@ -573,4 +575,4 @@ mergeInto(LibraryManager.library, { } } } -});
\ No newline at end of file +}); |