em-websocket 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/README.md +76 -0
- data/Rakefile +6 -28
- data/lib/em-websocket.rb +6 -2
- data/lib/em-websocket/connection.rb +53 -112
- data/lib/em-websocket/framing03.rb +176 -0
- data/lib/em-websocket/framing76.rb +96 -0
- data/lib/em-websocket/handler.rb +28 -4
- data/lib/em-websocket/handler03.rb +14 -0
- data/lib/em-websocket/handler75.rb +2 -15
- data/lib/em-websocket/handler76.rb +3 -56
- data/lib/em-websocket/handler_factory.rb +37 -12
- data/lib/em-websocket/handshake75.rb +21 -0
- data/lib/em-websocket/handshake76.rb +61 -0
- data/lib/em-websocket/version.rb +5 -0
- data/spec/helper.rb +12 -7
- data/spec/integration/draft03_spec.rb +252 -0
- data/spec/integration/{integration_spec.rb → draft76_spec.rb} +26 -1
- data/spec/unit/framing_spec.rb +108 -0
- data/spec/unit/handler_spec.rb +12 -0
- data/spec/websocket_spec.rb +16 -1
- metadata +51 -17
- data/README.rdoc +0 -73
- data/VERSION +0 -1
- data/examples/srv.rb +0 -19
data/README.rdoc
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
= EM-WebSocket
|
2
|
-
|
3
|
-
EventMachine based, async WebSocket server. Take a look at examples directory, or
|
4
|
-
check out the blog post below:
|
5
|
-
- http://www.igvita.com/2009/12/22/ruby-websockets-tcp-for-the-browser/
|
6
|
-
|
7
|
-
== Simple server example
|
8
|
-
|
9
|
-
EventMachine.run {
|
10
|
-
|
11
|
-
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |ws|
|
12
|
-
ws.onopen {
|
13
|
-
puts "WebSocket connection open"
|
14
|
-
|
15
|
-
# publish message to the client
|
16
|
-
ws.send "Hello Client"
|
17
|
-
}
|
18
|
-
|
19
|
-
ws.onclose { puts "Connection closed" }
|
20
|
-
ws.onmessage { |msg|
|
21
|
-
puts "Recieved message: #{msg}"
|
22
|
-
ws.send "Pong: #{msg}"
|
23
|
-
}
|
24
|
-
end
|
25
|
-
}
|
26
|
-
|
27
|
-
== Secure server
|
28
|
-
|
29
|
-
It is possible to accept secure wss:// connections by passing :secure => true when opening the connection. Safari 5 does not currently support prompting on untrusted SSL certificates therefore using signed certificates is highly recommended. Pass a :tls_options hash containing keys as described in http://eventmachine.rubyforge.org/EventMachine/Connection.html#M000296
|
30
|
-
|
31
|
-
For example,
|
32
|
-
|
33
|
-
EventMachine::WebSocket.start({
|
34
|
-
:host => "0.0.0.0",
|
35
|
-
:port => 443
|
36
|
-
:secure => true,
|
37
|
-
:tls_options => {
|
38
|
-
:private_key_file => "/private/key",
|
39
|
-
:cert_chain_file => "/ssl/certificate"
|
40
|
-
}
|
41
|
-
}) do |ws|
|
42
|
-
...
|
43
|
-
end
|
44
|
-
|
45
|
-
== Examples
|
46
|
-
- examples/multicast.rb - broadcast all ruby tweets to all subscribers
|
47
|
-
- examples/echo.rb - server <> client exchange via a websocket
|
48
|
-
- http://github.com/rubenfonseca/twitter-amqp-websocket-example
|
49
|
-
|
50
|
-
== License
|
51
|
-
|
52
|
-
(The MIT License)
|
53
|
-
|
54
|
-
Copyright (c) 2009 Ilya Grigorik
|
55
|
-
|
56
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
57
|
-
a copy of this software and associated documentation files (the
|
58
|
-
'Software'), to deal in the Software without restriction, including
|
59
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
60
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
61
|
-
permit persons to whom the Software is furnished to do so, subject to
|
62
|
-
the following conditions:
|
63
|
-
|
64
|
-
The above copyright notice and this permission notice shall be
|
65
|
-
included in all copies or substantial portions of the Software.
|
66
|
-
|
67
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
68
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
69
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
70
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
71
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
72
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
73
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.4
|
data/examples/srv.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'lib/em-websocket'
|
2
|
-
require 'sinatra/base'
|
3
|
-
require 'thin'
|
4
|
-
|
5
|
-
EM.run do
|
6
|
-
class App < Sinatra::Base
|
7
|
-
get '/' do
|
8
|
-
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
EM::WebSocket.start(:host => '0.0.0.0', :port => 3001) do
|
13
|
-
# Websocket code here
|
14
|
-
end
|
15
|
-
|
16
|
-
# You could also use Rainbows! instead of Thin.
|
17
|
-
# Any EM based Rack handler should do.
|
18
|
-
# Thin.start App, '0.0.0.0', 3000
|
19
|
-
end
|