_bushido-faye-websocket 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/CHANGELOG.txt +56 -0
  2. data/README.rdoc +366 -0
  3. data/examples/app.rb +50 -0
  4. data/examples/autobahn_client.rb +44 -0
  5. data/examples/client.rb +30 -0
  6. data/examples/config.ru +17 -0
  7. data/examples/haproxy.conf +21 -0
  8. data/examples/server.rb +44 -0
  9. data/examples/sse.html +39 -0
  10. data/examples/ws.html +44 -0
  11. data/ext/faye_websocket_mask/FayeWebsocketMaskService.java +61 -0
  12. data/ext/faye_websocket_mask/extconf.rb +5 -0
  13. data/ext/faye_websocket_mask/faye_websocket_mask.c +33 -0
  14. data/lib/faye/adapters/goliath.rb +47 -0
  15. data/lib/faye/adapters/rainbows.rb +32 -0
  16. data/lib/faye/adapters/rainbows_client.rb +70 -0
  17. data/lib/faye/adapters/thin.rb +62 -0
  18. data/lib/faye/eventsource.rb +124 -0
  19. data/lib/faye/websocket.rb +216 -0
  20. data/lib/faye/websocket/adapter.rb +21 -0
  21. data/lib/faye/websocket/api.rb +96 -0
  22. data/lib/faye/websocket/api/event.rb +33 -0
  23. data/lib/faye/websocket/api/event_target.rb +34 -0
  24. data/lib/faye/websocket/client.rb +84 -0
  25. data/lib/faye/websocket/draft75_parser.rb +87 -0
  26. data/lib/faye/websocket/draft76_parser.rb +84 -0
  27. data/lib/faye/websocket/hybi_parser.rb +320 -0
  28. data/lib/faye/websocket/hybi_parser/handshake.rb +78 -0
  29. data/lib/faye/websocket/hybi_parser/stream_reader.rb +29 -0
  30. data/lib/faye/websocket/utf8_match.rb +8 -0
  31. data/spec/faye/websocket/client_spec.rb +179 -0
  32. data/spec/faye/websocket/draft75_parser_examples.rb +48 -0
  33. data/spec/faye/websocket/draft75_parser_spec.rb +27 -0
  34. data/spec/faye/websocket/draft76_parser_spec.rb +34 -0
  35. data/spec/faye/websocket/hybi_parser_spec.rb +156 -0
  36. data/spec/rainbows.conf +3 -0
  37. data/spec/server.crt +15 -0
  38. data/spec/server.key +15 -0
  39. data/spec/spec_helper.rb +68 -0
  40. metadata +158 -0
@@ -0,0 +1,3 @@
1
+ Rainbows! do
2
+ use :EventMachine
3
+ end
@@ -0,0 +1,15 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIICZTCCAc4CCQDxyrJZrFA0vjANBgkqhkiG9w0BAQUFADB3MQswCQYDVQQGEwJV
3
+ SzEPMA0GA1UECBMGTG9uZG9uMQ8wDQYDVQQHEwZMb25kb24xDTALBgNVBAoTBEZh
4
+ eWUxFTATBgNVBAMTDEphbWVzIENvZ2xhbjEgMB4GCSqGSIb3DQEJARYRamNvZ2xh
5
+ bkBnbWFpbC5jb20wHhcNMTEwODMwMTIzOTM2WhcNMTIwODI5MTIzOTM2WjB3MQsw
6
+ CQYDVQQGEwJVSzEPMA0GA1UECBMGTG9uZG9uMQ8wDQYDVQQHEwZMb25kb24xDTAL
7
+ BgNVBAoTBEZheWUxFTATBgNVBAMTDEphbWVzIENvZ2xhbjEgMB4GCSqGSIb3DQEJ
8
+ ARYRamNvZ2xhbkBnbWFpbC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGB
9
+ AMDjU5fAK7fvUCZIYHcGXDZD/m9bY+B/UcwGcowk0hMQGYNlLKrpiK7xXBmZpDb6
10
+ r8n+7L/epBeSumbRIm4TDzeNHhuQGYLIeGQy7JNLoPBr6GxubjuJhKOOBnCqcupR
11
+ CLGG7Zw5oL4UvtZVH6kL9XnjyokQQbxxeoV9DqtqOaHHAgMBAAEwDQYJKoZIhvcN
12
+ AQEFBQADgYEAvQjSpzE1ahaeH1CmbLwckTxvWMZfxcZOrxTruK1po3cNnDOjGqFQ
13
+ KEkNj3K5WfwTBD4QgUdYDykhDX2m6HaMz4JEbgrwQv8M8FiswIA3dyGsbOifOk8H
14
+ r3GPNKMzm4o6vrn6RGOpt9q6bsWUBUHfNpP93uU2C9QEwDua3cFjDA0=
15
+ -----END CERTIFICATE-----
@@ -0,0 +1,15 @@
1
+ -----BEGIN RSA PRIVATE KEY-----
2
+ MIICXAIBAAKBgQDA41OXwCu371AmSGB3Blw2Q/5vW2Pgf1HMBnKMJNITEBmDZSyq
3
+ 6Yiu8VwZmaQ2+q/J/uy/3qQXkrpm0SJuEw83jR4bkBmCyHhkMuyTS6Dwa+hsbm47
4
+ iYSjjgZwqnLqUQixhu2cOaC+FL7WVR+pC/V548qJEEG8cXqFfQ6rajmhxwIDAQAB
5
+ AoGABlk1DiCQD8y7mZb2PdSiwlJ4lFewsNnf6lQn/v7TPzdfb5ir4LAxBHkDLACH
6
+ jBuyH3bZefMs+W2l3u5xMKhF7uJqYcUlJdH2UwRfNG54Hn4SGAjQOK3ONer99sUf
7
+ USlsWSX1HjAAFMCBwUfKxMZA3VNQfYKTPdm0jSVf85kHO1ECQQD3s6ksm3QpfD0L
8
+ eG9EoDrqmwnEfpKoWPpz1O0i5tY9VcmhmLwS5Zpd7lB1qjTqzZk4RygU73T/BseJ
9
+ azehIHK5AkEAx1mSXt+ec8RfzVi/io6oqi2vOcACXRbOG4NQmqUWPnumdwsJjsjR
10
+ RzEoDFC2lu6448p9sgEq+CkbmgVeiyp4fwJAQnmgySve/NMuvslPcyddKGD7OhSN
11
+ 30ghzrwx98/jZwqC1i9bKeccimDOjwVitjD/Ea9m/ldVGqwDGMoBX+iJYQJAEIOO
12
+ CYfyw1pQKV2huGOq+zX/nwQV7go2lrbhFX55gkGR/6iNaSOfmosq6yJAje5GqLAc
13
+ i4NnQNl+7NpnA5ZIFwJBAI1+OsZyjbRI99pYkTdOpa5IPlIb3j3JbSfjAWHLxlRY
14
+ 0HLvN3Q1mE9kbB+uKH6syF/S7nALgsLgq7eHYvIaE/A=
15
+ -----END RSA PRIVATE KEY-----
@@ -0,0 +1,68 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ unless RUBY_PLATFORM =~ /java/
5
+ require 'thin'
6
+ Thin::Logging.silent = true
7
+ require 'rainbows'
8
+ Unicorn::Configurator::DEFAULTS[:logger] = Logger.new(StringIO.new)
9
+ end
10
+
11
+ require File.expand_path('../../lib/faye/websocket', __FILE__)
12
+ require File.expand_path('../../vendor/em-rspec/lib/em-rspec', __FILE__)
13
+ require File.expand_path('../faye/websocket/draft75_parser_examples', __FILE__)
14
+
15
+ module EncodingHelper
16
+ def encode(message)
17
+ message.respond_to?(:force_encoding) ?
18
+ message.force_encoding("UTF-8") :
19
+ message
20
+ end
21
+
22
+ def bytes(string)
23
+ string.bytes.to_a
24
+ end
25
+
26
+ def parse(bytes)
27
+ @parser.parse(bytes.pack('C*'))
28
+ end
29
+ end
30
+
31
+ class EchoServer
32
+ def call(env)
33
+ socket = Faye::WebSocket.new(env, ["echo"])
34
+ socket.onmessage = lambda do |event|
35
+ socket.send(event.data)
36
+ end
37
+ socket.rack_response
38
+ end
39
+
40
+ def listen(port, backend, ssl = false)
41
+ case backend
42
+ when :rainbows
43
+ rackup = Unicorn::Configurator::RACKUP
44
+ rackup[:port] = port
45
+ rackup[:set_listener] = true
46
+ options = rackup[:options]
47
+ options[:config_file] = File.expand_path('../rainbows.conf', __FILE__)
48
+ @server = Rainbows::HttpServer.new(self, options)
49
+ @server.start
50
+ when :thin
51
+ Rack::Handler.get('thin').run(self, :Port => port) do |s|
52
+ if ssl
53
+ s.ssl = true
54
+ s.ssl_options = {
55
+ :private_key_file => File.expand_path('../server.key', __FILE__),
56
+ :cert_chain_file => File.expand_path('../server.crt', __FILE__)
57
+ }
58
+ end
59
+ @server = s
60
+ end
61
+ end
62
+ end
63
+
64
+ def stop
65
+ @server.stop
66
+ end
67
+ end
68
+
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: _bushido-faye-websocket
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.4.4
6
+ platform: ruby
7
+ authors:
8
+ - James Coglan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-03-31 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: eventmachine
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.12.0
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rack
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :development
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake-compiler
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 2.8.0
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: rainbows
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 1.0.0
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: thin
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 1.2.0
79
+ type: :development
80
+ version_requirements: *id006
81
+ description:
82
+ email: jcoglan@gmail.com
83
+ executables: []
84
+
85
+ extensions:
86
+ - ext/faye_websocket_mask/extconf.rb
87
+ extra_rdoc_files:
88
+ - README.rdoc
89
+ files:
90
+ - README.rdoc
91
+ - CHANGELOG.txt
92
+ - ext/faye_websocket_mask/faye_websocket_mask.c
93
+ - ext/faye_websocket_mask/FayeWebsocketMaskService.java
94
+ - ext/faye_websocket_mask/extconf.rb
95
+ - lib/faye/adapters/goliath.rb
96
+ - lib/faye/adapters/rainbows.rb
97
+ - lib/faye/adapters/rainbows_client.rb
98
+ - lib/faye/adapters/thin.rb
99
+ - lib/faye/eventsource.rb
100
+ - lib/faye/websocket/adapter.rb
101
+ - lib/faye/websocket/api/event.rb
102
+ - lib/faye/websocket/api/event_target.rb
103
+ - lib/faye/websocket/api.rb
104
+ - lib/faye/websocket/client.rb
105
+ - lib/faye/websocket/draft75_parser.rb
106
+ - lib/faye/websocket/draft76_parser.rb
107
+ - lib/faye/websocket/hybi_parser/handshake.rb
108
+ - lib/faye/websocket/hybi_parser/stream_reader.rb
109
+ - lib/faye/websocket/hybi_parser.rb
110
+ - lib/faye/websocket/utf8_match.rb
111
+ - lib/faye/websocket.rb
112
+ - examples/app.rb
113
+ - examples/autobahn_client.rb
114
+ - examples/client.rb
115
+ - examples/config.ru
116
+ - examples/haproxy.conf
117
+ - examples/server.rb
118
+ - examples/sse.html
119
+ - examples/ws.html
120
+ - spec/faye/websocket/client_spec.rb
121
+ - spec/faye/websocket/draft75_parser_examples.rb
122
+ - spec/faye/websocket/draft75_parser_spec.rb
123
+ - spec/faye/websocket/draft76_parser_spec.rb
124
+ - spec/faye/websocket/hybi_parser_spec.rb
125
+ - spec/rainbows.conf
126
+ - spec/server.crt
127
+ - spec/server.key
128
+ - spec/spec_helper.rb
129
+ homepage: http://github.com/faye/faye-websocket-ruby
130
+ licenses: []
131
+
132
+ post_install_message:
133
+ rdoc_options:
134
+ - --main
135
+ - README.rdoc
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: "0"
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: "0"
150
+ requirements: []
151
+
152
+ rubyforge_project:
153
+ rubygems_version: 1.8.17
154
+ signing_key:
155
+ specification_version: 3
156
+ summary: Standards-compliant WebSocket server and client
157
+ test_files: []
158
+