batman-rails-flo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +29 -0
  3. data/Rakefile +2 -0
  4. data/lib/batman-rails-flo.rb +5 -0
  5. data/lib/batman_rails_flo/railtie.rb +9 -0
  6. data/lib/batman_rails_flo/tasks.rake +14 -0
  7. data/lib/batman_rails_flo/version.rb +3 -0
  8. data/vendor/assets/javascripts/batman_rails_flo/flo_server.js +67 -0
  9. data/vendor/assets/javascripts/batman_rails_flo/live_reload.js.coffee +129 -0
  10. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CNAME +1 -0
  11. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CONTRIBUTING.md +9 -0
  12. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/LICENSE +22 -0
  13. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/README +50 -0
  14. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/cake +7 -0
  15. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/coffee +7 -0
  16. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/browser.js +134 -0
  17. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/cake.js +112 -0
  18. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/coffee-script.js +335 -0
  19. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/command.js +569 -0
  20. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/grammar.js +631 -0
  21. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/helpers.js +252 -0
  22. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
  23. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/lexer.js +926 -0
  24. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/nodes.js +3158 -0
  25. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/optparse.js +139 -0
  26. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/parser.js +724 -0
  27. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/register.js +66 -0
  28. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/repl.js +163 -0
  29. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/rewriter.js +475 -0
  30. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
  31. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/sourcemap.js +161 -0
  32. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/LICENSE +21 -0
  33. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/examples/pow.js +6 -0
  34. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/index.js +82 -0
  35. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/package.json +34 -0
  36. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/readme.markdown +63 -0
  37. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/chmod.js +38 -0
  38. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/clobber.js +37 -0
  39. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/mkdirp.js +28 -0
  40. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm.js +32 -0
  41. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm_sync.js +39 -0
  42. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/race.js +41 -0
  43. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/rel.js +32 -0
  44. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return.js +25 -0
  45. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return_sync.js +24 -0
  46. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/root.js +18 -0
  47. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/sync.js +32 -0
  48. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask.js +28 -0
  49. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask_sync.js +32 -0
  50. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/package.json +50 -0
  51. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/register.js +1 -0
  52. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/LICENSE +30 -0
  53. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/PATENTS +23 -0
  54. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/README.md +124 -0
  55. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/bin/flo +26 -0
  56. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.html +57 -0
  57. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.js +205 -0
  58. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/style.css +334 -0
  59. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/connection.js +235 -0
  60. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/devtools.html +12 -0
  61. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/index.js +323 -0
  62. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logger.js +42 -0
  63. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logo.png +0 -0
  64. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/manifest.json +13 -0
  65. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/session.js +305 -0
  66. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/index.js +10 -0
  67. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/flo.js +226 -0
  68. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/server.js +94 -0
  69. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/README.md +66 -0
  70. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/index.js +437 -0
  71. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/LICENSE +23 -0
  72. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/README.md +218 -0
  73. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/minimatch.js +1055 -0
  74. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
  75. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
  76. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
  77. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
  78. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/package.json +33 -0
  79. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
  80. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
  81. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
  82. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
  83. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
  84. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
  85. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/package.json +42 -0
  86. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
  87. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
  88. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/package.json +40 -0
  89. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/basic.js +399 -0
  90. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/brace-expand.js +33 -0
  91. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/caching.js +14 -0
  92. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/defaults.js +274 -0
  93. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
  94. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/lib/walker.js +111 -0
  95. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/license +13 -0
  96. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/lib/makeerror.js +87 -0
  97. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/lib/tmpl.js +17 -0
  98. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/package.json +31 -0
  99. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/readme.md +10 -0
  100. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/package.json +34 -0
  101. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/readme.md +77 -0
  102. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/package.json +36 -0
  103. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/readme.md +52 -0
  104. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/LICENSE +55 -0
  105. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/main.js +128 -0
  106. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/package.json +34 -0
  107. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/readme.mkd +72 -0
  108. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/d/t +0 -0
  109. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/t +0 -0
  110. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitor.js +31 -0
  111. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitorRootDirectory.js +28 -0
  112. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_watchTree.js +20 -0
  113. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/package.json +45 -0
  114. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/test/test.js +243 -0
  115. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/CHANGELOG.md +81 -0
  116. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/LICENSE +177 -0
  117. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/Makefile +11 -0
  118. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/README.md +245 -0
  119. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/binding.gyp +14 -0
  120. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Makefile +355 -0
  121. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/linker.lock +0 -0
  122. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/validation/src/validation.o +0 -0
  123. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/xor/src/xor.o +0 -0
  124. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/validation.node +0 -0
  125. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/xor.node +0 -0
  126. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/binding.Makefile +6 -0
  127. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/config.gypi +115 -0
  128. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/gyp-mac-tool +512 -0
  129. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/validation.target.mk +154 -0
  130. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/xor.target.mk +154 -0
  131. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/index.js +1 -0
  132. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/install.js +31 -0
  133. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Constants.js +23 -0
  134. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Deprecation.js +38 -0
  135. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.fallback.js +12 -0
  136. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.js +18 -0
  137. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketClient.js +359 -0
  138. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketConnection.js +717 -0
  139. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketFrame.js +282 -0
  140. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRequest.js +478 -0
  141. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouter.js +154 -0
  142. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouterRequest.js +59 -0
  143. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketServer.js +216 -0
  144. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/utils.js +7 -0
  145. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/websocket.js +11 -0
  146. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.fallback.js +13 -0
  147. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.js +18 -0
  148. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/package.json +43 -0
  149. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/validation.cc +144 -0
  150. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/xor.cpp +86 -0
  151. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/FastBufferList.js +192 -0
  152. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/LICENSE +18 -0
  153. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/ctio-faster.js +1126 -0
  154. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/package.json +25 -0
  155. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/browser_websocket.js +63 -0
  156. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/connection_test.js +57 -0
  157. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/logger_mock.js +15 -0
  158. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/session_test.js +194 -0
  159. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/server/flo_test.js +211 -0
  160. data/vendor/assets/javascripts/batman_rails_flo/package.json +15 -0
  161. data/vendor/assets/javascripts/batman_rails_flo/reload_event_handler.js.coffee +56 -0
  162. metadata +232 -0
@@ -0,0 +1,154 @@
1
+ # This file is generated by gyp; do not edit.
2
+
3
+ TOOLSET := target
4
+ TARGET := validation
5
+ DEFS_Debug := \
6
+ '-D_DARWIN_USE_64_BIT_INODE=1' \
7
+ '-D_LARGEFILE_SOURCE' \
8
+ '-D_FILE_OFFSET_BITS=64' \
9
+ '-DBUILDING_NODE_EXTENSION' \
10
+ '-DDEBUG' \
11
+ '-D_DEBUG'
12
+
13
+ # Flags passed to all source files.
14
+ CFLAGS_Debug := \
15
+ -O0 \
16
+ -gdwarf-2 \
17
+ -mmacosx-version-min=10.5 \
18
+ -arch x86_64 \
19
+ -Wall \
20
+ -Wendif-labels \
21
+ -W \
22
+ -Wno-unused-parameter
23
+
24
+ # Flags passed to only C files.
25
+ CFLAGS_C_Debug := \
26
+ -fno-strict-aliasing
27
+
28
+ # Flags passed to only C++ files.
29
+ CFLAGS_CC_Debug := \
30
+ -fno-rtti \
31
+ -fno-exceptions \
32
+ -fno-threadsafe-statics \
33
+ -fno-strict-aliasing
34
+
35
+ # Flags passed to only ObjC files.
36
+ CFLAGS_OBJC_Debug :=
37
+
38
+ # Flags passed to only ObjC++ files.
39
+ CFLAGS_OBJCC_Debug :=
40
+
41
+ INCS_Debug := \
42
+ -I/Users/rmosolgo/.node-gyp/0.10.26/src \
43
+ -I/Users/rmosolgo/.node-gyp/0.10.26/deps/uv/include \
44
+ -I/Users/rmosolgo/.node-gyp/0.10.26/deps/v8/include
45
+
46
+ DEFS_Release := \
47
+ '-D_DARWIN_USE_64_BIT_INODE=1' \
48
+ '-D_LARGEFILE_SOURCE' \
49
+ '-D_FILE_OFFSET_BITS=64' \
50
+ '-DBUILDING_NODE_EXTENSION'
51
+
52
+ # Flags passed to all source files.
53
+ CFLAGS_Release := \
54
+ -Os \
55
+ -gdwarf-2 \
56
+ -mmacosx-version-min=10.5 \
57
+ -arch x86_64 \
58
+ -Wall \
59
+ -Wendif-labels \
60
+ -W \
61
+ -Wno-unused-parameter
62
+
63
+ # Flags passed to only C files.
64
+ CFLAGS_C_Release := \
65
+ -fno-strict-aliasing
66
+
67
+ # Flags passed to only C++ files.
68
+ CFLAGS_CC_Release := \
69
+ -fno-rtti \
70
+ -fno-exceptions \
71
+ -fno-threadsafe-statics \
72
+ -fno-strict-aliasing
73
+
74
+ # Flags passed to only ObjC files.
75
+ CFLAGS_OBJC_Release :=
76
+
77
+ # Flags passed to only ObjC++ files.
78
+ CFLAGS_OBJCC_Release :=
79
+
80
+ INCS_Release := \
81
+ -I/Users/rmosolgo/.node-gyp/0.10.26/src \
82
+ -I/Users/rmosolgo/.node-gyp/0.10.26/deps/uv/include \
83
+ -I/Users/rmosolgo/.node-gyp/0.10.26/deps/v8/include
84
+
85
+ OBJS := \
86
+ $(obj).target/$(TARGET)/src/validation.o
87
+
88
+ # Add to the list of files we specially track dependencies for.
89
+ all_deps += $(OBJS)
90
+
91
+ # CFLAGS et al overrides must be target-local.
92
+ # See "Target-specific Variable Values" in the GNU Make manual.
93
+ $(OBJS): TOOLSET := $(TOOLSET)
94
+ $(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
95
+ $(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
96
+ $(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
97
+ $(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))
98
+
99
+ # Suffix rules, putting all outputs into $(obj).
100
+
101
+ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
102
+ @$(call do_cmd,cxx,1)
103
+
104
+ # Try building from generated source, too.
105
+
106
+ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
107
+ @$(call do_cmd,cxx,1)
108
+
109
+ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
110
+ @$(call do_cmd,cxx,1)
111
+
112
+ # End of this set of suffix rules
113
+ ### Rules for final target.
114
+ LDFLAGS_Debug := \
115
+ -Wl,-search_paths_first \
116
+ -mmacosx-version-min=10.5 \
117
+ -arch x86_64 \
118
+ -L$(builddir)
119
+
120
+ LIBTOOLFLAGS_Debug := \
121
+ -Wl,-search_paths_first
122
+
123
+ LDFLAGS_Release := \
124
+ -Wl,-search_paths_first \
125
+ -mmacosx-version-min=10.5 \
126
+ -arch x86_64 \
127
+ -L$(builddir)
128
+
129
+ LIBTOOLFLAGS_Release := \
130
+ -Wl,-search_paths_first
131
+
132
+ LIBS := \
133
+ -undefined dynamic_lookup
134
+
135
+ $(builddir)/validation.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
136
+ $(builddir)/validation.node: LIBS := $(LIBS)
137
+ $(builddir)/validation.node: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
138
+ $(builddir)/validation.node: TOOLSET := $(TOOLSET)
139
+ $(builddir)/validation.node: $(OBJS) FORCE_DO_CMD
140
+ $(call do_cmd,solink_module)
141
+
142
+ all_deps += $(builddir)/validation.node
143
+ # Add target alias
144
+ .PHONY: validation
145
+ validation: $(builddir)/validation.node
146
+
147
+ # Short alias for building this executable.
148
+ .PHONY: validation.node
149
+ validation.node: $(builddir)/validation.node
150
+
151
+ # Add executable to "all" target.
152
+ .PHONY: all
153
+ all: $(builddir)/validation.node
154
+
@@ -0,0 +1,154 @@
1
+ # This file is generated by gyp; do not edit.
2
+
3
+ TOOLSET := target
4
+ TARGET := xor
5
+ DEFS_Debug := \
6
+ '-D_DARWIN_USE_64_BIT_INODE=1' \
7
+ '-D_LARGEFILE_SOURCE' \
8
+ '-D_FILE_OFFSET_BITS=64' \
9
+ '-DBUILDING_NODE_EXTENSION' \
10
+ '-DDEBUG' \
11
+ '-D_DEBUG'
12
+
13
+ # Flags passed to all source files.
14
+ CFLAGS_Debug := \
15
+ -O0 \
16
+ -gdwarf-2 \
17
+ -mmacosx-version-min=10.5 \
18
+ -arch x86_64 \
19
+ -Wall \
20
+ -Wendif-labels \
21
+ -W \
22
+ -Wno-unused-parameter
23
+
24
+ # Flags passed to only C files.
25
+ CFLAGS_C_Debug := \
26
+ -fno-strict-aliasing
27
+
28
+ # Flags passed to only C++ files.
29
+ CFLAGS_CC_Debug := \
30
+ -fno-rtti \
31
+ -fno-exceptions \
32
+ -fno-threadsafe-statics \
33
+ -fno-strict-aliasing
34
+
35
+ # Flags passed to only ObjC files.
36
+ CFLAGS_OBJC_Debug :=
37
+
38
+ # Flags passed to only ObjC++ files.
39
+ CFLAGS_OBJCC_Debug :=
40
+
41
+ INCS_Debug := \
42
+ -I/Users/rmosolgo/.node-gyp/0.10.26/src \
43
+ -I/Users/rmosolgo/.node-gyp/0.10.26/deps/uv/include \
44
+ -I/Users/rmosolgo/.node-gyp/0.10.26/deps/v8/include
45
+
46
+ DEFS_Release := \
47
+ '-D_DARWIN_USE_64_BIT_INODE=1' \
48
+ '-D_LARGEFILE_SOURCE' \
49
+ '-D_FILE_OFFSET_BITS=64' \
50
+ '-DBUILDING_NODE_EXTENSION'
51
+
52
+ # Flags passed to all source files.
53
+ CFLAGS_Release := \
54
+ -Os \
55
+ -gdwarf-2 \
56
+ -mmacosx-version-min=10.5 \
57
+ -arch x86_64 \
58
+ -Wall \
59
+ -Wendif-labels \
60
+ -W \
61
+ -Wno-unused-parameter
62
+
63
+ # Flags passed to only C files.
64
+ CFLAGS_C_Release := \
65
+ -fno-strict-aliasing
66
+
67
+ # Flags passed to only C++ files.
68
+ CFLAGS_CC_Release := \
69
+ -fno-rtti \
70
+ -fno-exceptions \
71
+ -fno-threadsafe-statics \
72
+ -fno-strict-aliasing
73
+
74
+ # Flags passed to only ObjC files.
75
+ CFLAGS_OBJC_Release :=
76
+
77
+ # Flags passed to only ObjC++ files.
78
+ CFLAGS_OBJCC_Release :=
79
+
80
+ INCS_Release := \
81
+ -I/Users/rmosolgo/.node-gyp/0.10.26/src \
82
+ -I/Users/rmosolgo/.node-gyp/0.10.26/deps/uv/include \
83
+ -I/Users/rmosolgo/.node-gyp/0.10.26/deps/v8/include
84
+
85
+ OBJS := \
86
+ $(obj).target/$(TARGET)/src/xor.o
87
+
88
+ # Add to the list of files we specially track dependencies for.
89
+ all_deps += $(OBJS)
90
+
91
+ # CFLAGS et al overrides must be target-local.
92
+ # See "Target-specific Variable Values" in the GNU Make manual.
93
+ $(OBJS): TOOLSET := $(TOOLSET)
94
+ $(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
95
+ $(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
96
+ $(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
97
+ $(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))
98
+
99
+ # Suffix rules, putting all outputs into $(obj).
100
+
101
+ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD
102
+ @$(call do_cmd,cxx,1)
103
+
104
+ # Try building from generated source, too.
105
+
106
+ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD
107
+ @$(call do_cmd,cxx,1)
108
+
109
+ $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cpp FORCE_DO_CMD
110
+ @$(call do_cmd,cxx,1)
111
+
112
+ # End of this set of suffix rules
113
+ ### Rules for final target.
114
+ LDFLAGS_Debug := \
115
+ -Wl,-search_paths_first \
116
+ -mmacosx-version-min=10.5 \
117
+ -arch x86_64 \
118
+ -L$(builddir)
119
+
120
+ LIBTOOLFLAGS_Debug := \
121
+ -Wl,-search_paths_first
122
+
123
+ LDFLAGS_Release := \
124
+ -Wl,-search_paths_first \
125
+ -mmacosx-version-min=10.5 \
126
+ -arch x86_64 \
127
+ -L$(builddir)
128
+
129
+ LIBTOOLFLAGS_Release := \
130
+ -Wl,-search_paths_first
131
+
132
+ LIBS := \
133
+ -undefined dynamic_lookup
134
+
135
+ $(builddir)/xor.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
136
+ $(builddir)/xor.node: LIBS := $(LIBS)
137
+ $(builddir)/xor.node: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
138
+ $(builddir)/xor.node: TOOLSET := $(TOOLSET)
139
+ $(builddir)/xor.node: $(OBJS) FORCE_DO_CMD
140
+ $(call do_cmd,solink_module)
141
+
142
+ all_deps += $(builddir)/xor.node
143
+ # Add target alias
144
+ .PHONY: xor
145
+ xor: $(builddir)/xor.node
146
+
147
+ # Short alias for building this executable.
148
+ .PHONY: xor.node
149
+ xor.node: $(builddir)/xor.node
150
+
151
+ # Add executable to "all" target.
152
+ .PHONY: all
153
+ all: $(builddir)/xor.node
154
+
@@ -0,0 +1 @@
1
+ module.exports = require('./lib/websocket');
@@ -0,0 +1,31 @@
1
+ var spawn = require('child_process').spawn
2
+ , exec = require('child_process').exec
3
+ , fs = require('fs')
4
+ , version = JSON.parse(fs.readFileSync(__dirname + '/package.json', 'utf8')).version
5
+ , verbose = process.env['npm_package_config_verbose'] != null ? process.env['npm_package_config_verbose'] === 'true' : false;
6
+
7
+ console.log('[websocket v%s] Attempting to compile native extensions.', version);
8
+
9
+ var gyp = exec('node-gyp rebuild', {cwd: __dirname});
10
+ gyp.stdout.on('data', function(data) {
11
+ if (verbose) process.stdout.write(data);
12
+ });
13
+ gyp.stderr.on('data', function(data) {
14
+ if (verbose) process.stdout.write(data);
15
+ });
16
+ gyp.on('exit', function(code) {
17
+ if (code !== 0) {
18
+ console.log("[websocket v%s]", version);
19
+ console.log(' Native code compile failed!!');
20
+ console.log(' Please note that this module DOES NOT REQUIRE the native components');
21
+ console.log(' and will still work without them, though not quite as efficiently.');
22
+ console.log('');
23
+ console.log(' On Windows, native extensions require Visual Studio and Python.');
24
+ console.log(' On Unix, native extensions require Python, make and a C++ compiler.');
25
+ console.log(' Start npm with --websocket:verbose to show compilation output (if any).');
26
+ }
27
+ else {
28
+ console.log('[websocket v%s] Native extension compilation successful!', version);
29
+ }
30
+ process.exit();
31
+ });
@@ -0,0 +1,23 @@
1
+ /************************************************************************
2
+ * Copyright 2010-2011 Worlize Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ ***********************************************************************/
16
+
17
+ var extend = require('./utils').extend;
18
+ var util = require('util');
19
+
20
+ var Constants = {
21
+ "DEBUG" : false
22
+ };
23
+ module.exports = Constants;
@@ -0,0 +1,38 @@
1
+ /************************************************************************
2
+ * Copyright 2010-2011 Worlize Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ ***********************************************************************/
16
+
17
+ var extend = require('./utils').extend;
18
+ var util = require('util');
19
+
20
+ var Deprecation = {
21
+ disableWarnings: false,
22
+
23
+ deprecationWarningMap: {
24
+ websocketVersion:
25
+ "The websocketVersion property will be removed in a future version of WebSocket-Node. It was renamed to webSocketVersion for naming consistency.",
26
+
27
+ websocketVersionConfig:
28
+ "The websocketVersion config value will be removed in a future version of WebSocket-Node. It was renamed to webSocketVersion for naming consistency."
29
+ },
30
+
31
+ warn: function(deprecationName) {
32
+ if (!this.disableWarnings && this.deprecationWarningMap[deprecationName]) {
33
+ console.warn("DEPRECATION WARNING: " + this.deprecationWarningMap[deprecationName]);
34
+ this.deprecationWarningMap[deprecationName] = false;
35
+ }
36
+ }
37
+ };
38
+ module.exports = Deprecation;
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * UTF-8 Validation Fallback Code originally from:
3
+ * ws: a node.js websocket client
4
+ * Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ module.exports.Validation = {
9
+ isValidUTF8: function(buffer) {
10
+ return true;
11
+ }
12
+ };
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * UTF-8 Validation Code originally from:
3
+ * ws: a node.js websocket client
4
+ * Copyright(c) 2011 Einar Otto Stangvik <einaros@gmail.com>
5
+ * MIT Licensed
6
+ */
7
+
8
+ try {
9
+ module.exports = require('../build/Release/validation');
10
+ } catch (e) { try {
11
+ module.exports = require('../build/default/validation');
12
+ } catch (e) { try {
13
+ module.exports = require('./Validation.fallback');
14
+ console.warn("Warning: Native modules not compiled. UTF-8 validation disabled.")
15
+ } catch (e) {
16
+ console.error("validation.node seems not to have been built. Run npm install.")
17
+ throw e;
18
+ }}}
@@ -0,0 +1,359 @@
1
+ /************************************************************************
2
+ * Copyright 2010-2011 Worlize Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ ***********************************************************************/
16
+
17
+ var deprecation = require('./Deprecation');
18
+
19
+ var nodeVersion = process.version.slice(1).split('.').map(function(item) { return parseInt(item, 10); });
20
+ var isNode0_4_x = (nodeVersion[0] === 0 && nodeVersion[1] === 4);
21
+ var isGreaterThanNode0_4_x = (nodeVersion[0] > 0 || (nodeVersion[0] === 0 && nodeVersion[1] > 4));
22
+
23
+ var extend = require('./utils').extend;
24
+ var util = require('util');
25
+ var EventEmitter = require('events').EventEmitter;
26
+ var http = require('http');
27
+ var https = require('https');
28
+ var url = require('url');
29
+ var crypto = require('crypto');
30
+ var WebSocketConnection = require('./WebSocketConnection');
31
+
32
+ const INIT = -1;
33
+ const CONNECTING = 0;
34
+ const OPEN = 1;
35
+ const CLOSING = 2;
36
+ const CLOSED = 3;
37
+
38
+ var ID_COUNTER = 0;
39
+
40
+ var protocolSeparators = [
41
+ "(", ")", "<", ">", "@",
42
+ ",", ";", ":", "\\", "\"",
43
+ "/", "[", "]", "?", "=",
44
+ "{", "}", " ", String.fromCharCode(9)
45
+ ];
46
+
47
+ function WebSocketClient(config) {
48
+ // TODO: Implement extensions
49
+
50
+ this.config = {
51
+ // 1MiB max frame size.
52
+ maxReceivedFrameSize: 0x100000,
53
+
54
+ // 8MiB max message size, only applicable if
55
+ // assembleFragments is true
56
+ maxReceivedMessageSize: 0x800000,
57
+
58
+ // Outgoing messages larger than fragmentationThreshold will be
59
+ // split into multiple fragments.
60
+ fragmentOutgoingMessages: true,
61
+
62
+ // Outgoing frames are fragmented if they exceed this threshold.
63
+ // Default is 16KiB
64
+ fragmentationThreshold: 0x4000,
65
+
66
+ // Which version of the protocol to use for this session. This
67
+ // option will be removed once the protocol is finalized by the IETF
68
+ // It is only available to ease the transition through the
69
+ // intermediate draft protocol versions.
70
+ // At present, it only affects the name of the Origin header.
71
+ webSocketVersion: 13,
72
+
73
+ // If true, fragmented messages will be automatically assembled
74
+ // and the full message will be emitted via a 'message' event.
75
+ // If false, each frame will be emitted via a 'frame' event and
76
+ // the application will be responsible for aggregating multiple
77
+ // fragmented frames. Single-frame messages will emit a 'message'
78
+ // event in addition to the 'frame' event.
79
+ // Most users will want to leave this set to 'true'
80
+ assembleFragments: true,
81
+
82
+ // The Nagle Algorithm makes more efficient use of network resources
83
+ // by introducing a small delay before sending small packets so that
84
+ // multiple messages can be batched together before going onto the
85
+ // wire. This however comes at the cost of latency, so the default
86
+ // is to disable it. If you don't need low latency and are streaming
87
+ // lots of small messages, you can change this to 'false'
88
+ disableNagleAlgorithm: true,
89
+
90
+ // The number of milliseconds to wait after sending a close frame
91
+ // for an acknowledgement to come back before giving up and just
92
+ // closing the socket.
93
+ closeTimeout: 5000,
94
+
95
+ // Options to pass to https.connect if connecting via TLS
96
+ tlsOptions: {}
97
+ };
98
+ if (config) {
99
+ extend(this.config, config);
100
+ }
101
+ if ('websocketVersion' in this.config) {
102
+ console.dir(this.config);
103
+ deprecation.warn('websocketVersionConfig');
104
+ this.config.webSocketVersion = this.config.websocketVersion;
105
+ }
106
+ Object.defineProperty(this.config, 'websocketVersion', {
107
+ set: function(value) {
108
+ deprecation.warn('websocketVersionConfig');
109
+ this.webSocketVersion = value;
110
+ },
111
+ get: function() {
112
+ deprecation.warn('websocketVersionConfig');
113
+ return this.webSocketVersion;
114
+ }
115
+ });
116
+
117
+ switch (this.config.webSocketVersion) {
118
+ case 8:
119
+ case 13:
120
+ break;
121
+ default:
122
+ throw new Error("Requested webSocketVersion is not supported. " +
123
+ "Allowed values are 8 and 13.");
124
+ }
125
+
126
+ this.readyState = INIT;
127
+ }
128
+
129
+ util.inherits(WebSocketClient, EventEmitter);
130
+
131
+ WebSocketClient.prototype.connect = function(requestUrl, protocols, origin, headers) {
132
+ var self = this;
133
+ if (typeof(protocols) === 'string') {
134
+ protocols = [protocols];
135
+ }
136
+ if (!(protocols instanceof Array)) {
137
+ protocols = [];
138
+ }
139
+ this.protocols = protocols;
140
+ this.origin = origin;
141
+
142
+ if (typeof(requestUrl) === 'string') {
143
+ this.url = url.parse(requestUrl);
144
+ }
145
+ else {
146
+ this.url = requestUrl; // in case an already parsed url is passed in.
147
+ }
148
+ if (!this.url.protocol) {
149
+ throw new Error("You must specify a full WebSocket URL, including protocol.");
150
+ }
151
+ if (!this.url.host) {
152
+ throw new Error("You must specify a full WebSocket URL, including hostname. Relative URLs are not supported.");
153
+ }
154
+
155
+ this.secure = (this.url.protocol === 'wss:');
156
+
157
+ // validate protocol characters:
158
+ this.protocols.forEach(function(protocol, index, array) {
159
+ for (var i=0; i < protocol.length; i ++) {
160
+ var charCode = protocol.charCodeAt(i);
161
+ var character = protocol.charAt(i);
162
+ if (charCode < 0x0021 || charCode > 0x007E || protocolSeparators.indexOf(character) !== -1) {
163
+ throw new Error("Protocol list contains invalid character '" + String.fromCharCode(charCode) + "'");
164
+ }
165
+ }
166
+ });
167
+
168
+ var defaultPorts = {
169
+ 'ws:': '80',
170
+ 'wss:': '443'
171
+ };
172
+
173
+ if (!this.url.port) {
174
+ this.url.port = defaultPorts[this.url.protocol];
175
+ }
176
+
177
+ var nonce = new Buffer(16);
178
+ for (var i=0; i < 16; i++) {
179
+ nonce[i] = Math.round(Math.random()*0xFF);
180
+ }
181
+ this.base64nonce = nonce.toString('base64');
182
+
183
+ var hostHeaderValue = this.url.hostname;
184
+ if ((this.url.protocol === 'ws:' && this.url.port !== '80') ||
185
+ (this.url.protocol === 'wss:' && this.url.port !== '443')) {
186
+ hostHeaderValue += (":" + this.url.port)
187
+ }
188
+
189
+ var reqHeaders = {};
190
+ extend(reqHeaders, headers || {});
191
+ extend(reqHeaders, {
192
+ 'Upgrade': 'websocket',
193
+ 'Connection': 'Upgrade',
194
+ 'Sec-WebSocket-Version': this.config.webSocketVersion.toString(10),
195
+ 'Sec-WebSocket-Key': this.base64nonce,
196
+ 'Host': hostHeaderValue
197
+ });
198
+
199
+ if (this.protocols.length > 0) {
200
+ reqHeaders['Sec-WebSocket-Protocol'] = this.protocols.join(', ');
201
+ }
202
+ if (this.origin) {
203
+ if (this.config.webSocketVersion === 13) {
204
+ reqHeaders['Origin'] = this.origin;
205
+ }
206
+ else if (this.config.webSocketVersion === 8) {
207
+ reqHeaders['Sec-WebSocket-Origin'] = this.origin;
208
+ }
209
+ }
210
+
211
+ // TODO: Implement extensions
212
+
213
+ var pathAndQuery = this.url.pathname;
214
+ if (this.url.search) {
215
+ pathAndQuery += this.url.search;
216
+ }
217
+
218
+ function handleRequestError(error) {
219
+ self.emit('connectFailed', error);
220
+ }
221
+
222
+ if (isNode0_4_x) {
223
+ // Using old http.createClient interface since the new Agent-based API
224
+ // is buggy in Node 0.4.x.
225
+ if (this.secure) {
226
+ throw new Error("TLS connections are not supported under Node 0.4.x. Please use 0.6.2 or newer.");
227
+ }
228
+ var client = http.createClient(this.url.port, this.url.hostname);
229
+ client.on('error', handleRequestError);
230
+ client.on('upgrade', function handleClientUpgrade(response, socket, head) {
231
+ client.removeListener('error', handleRequestError);
232
+ self.socket = socket;
233
+ self.response = response;
234
+ self.firstDataChunk = head;
235
+ self.validateHandshake();
236
+ });
237
+ var req = client.request(pathAndQuery, reqHeaders);
238
+ }
239
+ else if (isGreaterThanNode0_4_x) {
240
+ var requestOptions = {
241
+ hostname: this.url.hostname,
242
+ port: this.url.port,
243
+ method: 'GET',
244
+ path: pathAndQuery,
245
+ headers: reqHeaders,
246
+ agent: false
247
+ };
248
+ if (this.secure) {
249
+ ['key','passphrase','cert','ca'].forEach(function(key) {
250
+ if (self.config.tlsOptions.hasOwnProperty(key)) {
251
+ requestOptions[key] = self.config.tlsOptions[key];
252
+ }
253
+ });
254
+ var req = https.request(requestOptions);
255
+ }
256
+ else {
257
+ var req = http.request(requestOptions);
258
+ }
259
+ req.on('upgrade', function handleRequestUpgrade(response, socket, head) {
260
+ req.removeListener('error', handleRequestError);
261
+ self.socket = socket;
262
+ self.response = response;
263
+ self.firstDataChunk = head;
264
+ self.validateHandshake();
265
+ });
266
+ req.on('error', handleRequestError);
267
+ }
268
+ else {
269
+ throw new Error("Unsupported Node version " + process.version);
270
+ }
271
+
272
+ req.on('response', function(response) {
273
+ var headerDumpParts = [];
274
+ for (var headerName in response.headers) {
275
+ headerDumpParts.push(headerName + ": " + response.headers[headerName]);
276
+ }
277
+ self.failHandshake(
278
+ "Server responded with a non-101 status: " +
279
+ response.statusCode +
280
+ "\nResponse Headers Follow:\n" +
281
+ headerDumpParts.join('\n') + "\n"
282
+ );
283
+ });
284
+ req.end();
285
+ };
286
+
287
+ WebSocketClient.prototype.validateHandshake = function() {
288
+ var headers = this.response.headers;
289
+
290
+ if (this.protocols.length > 0) {
291
+ this.protocol = headers['sec-websocket-protocol'];
292
+ if (this.protocol) {
293
+ if (this.protocols.indexOf(this.protocol) === -1) {
294
+ this.failHandshake("Server did not respond with a requested protocol.");
295
+ return;
296
+ }
297
+ }
298
+ else {
299
+ this.failHandshake("Expected a Sec-WebSocket-Protocol header.");
300
+ return;
301
+ }
302
+ }
303
+
304
+ if (!(headers['connection'] && headers['connection'].toLocaleLowerCase() === 'upgrade')) {
305
+ this.failHandshake("Expected a Connection: Upgrade header from the server");
306
+ return;
307
+ }
308
+
309
+ if (!(headers['upgrade'] && headers['upgrade'].toLocaleLowerCase() === 'websocket')) {
310
+ this.failHandshake("Expected an Upgrade: websocket header from the server");
311
+ return;
312
+ }
313
+
314
+ var sha1 = crypto.createHash('sha1');
315
+ sha1.update(this.base64nonce + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
316
+ var expectedKey = sha1.digest('base64');
317
+
318
+ if (!headers['sec-websocket-accept']) {
319
+ this.failHandshake("Expected Sec-WebSocket-Accept header from server");
320
+ return;
321
+ }
322
+
323
+ if (!(headers['sec-websocket-accept'] === expectedKey)) {
324
+ this.failHandshake("Sec-WebSocket-Accept header from server didn't match expected value of " + expectedKey);
325
+ return;
326
+ }
327
+
328
+ // TODO: Support extensions
329
+
330
+ this.succeedHandshake();
331
+ };
332
+
333
+ WebSocketClient.prototype.failHandshake = function(errorDescription) {
334
+ if (this.socket && this.socket.writable) {
335
+ this.socket.end();
336
+ }
337
+ this.emit('connectFailed', errorDescription);
338
+ };
339
+
340
+ WebSocketClient.prototype.succeedHandshake = function() {
341
+ var connection = new WebSocketConnection(this.socket, [], this.protocol, true, this.config);
342
+
343
+ connection.webSocketVersion = this.config.webSocketVersion;
344
+ // Deprecated websocketVersion (proper casing...)
345
+ Object.defineProperty(connection, "websocketVersion", {
346
+ get: function() {
347
+ deprecation.warn('websocketVersion');
348
+ return this.webSocketVersion;
349
+ }
350
+ });
351
+
352
+ this.emit('connect', connection);
353
+ if (this.firstDataChunk.length > 0) {
354
+ connection.handleSocketData(this.firstDataChunk);
355
+ }
356
+ this.firstDataChunk = null;
357
+ };
358
+
359
+ module.exports = WebSocketClient;