websocket-rack 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,9 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2 / 2011-03-08
4
+
5
+ - change Rack::WebSocket::Application @connection variable name to @conn - first one is to often used to block it
6
+ - allow debugging of WebSocket connection
7
+
3
8
  ## 0.1.1 / 2011-03-07
4
9
 
5
10
  - add missing gem dependencies
6
- - clear connection inactivity timeout for websocket connections
11
+ - clear connection inactivity timeout for WebSocket connections
7
12
  - inform about bug in EM < 1.0.0
8
13
  - add thin-websocket wrapper around thin binary
9
14
 
data/README.md CHANGED
@@ -105,6 +105,10 @@ Currently only Thin. I plan to support also Rainbows! in future, but not yet.
105
105
 
106
106
  This is bug in EventMachine < 1.0.0. Please consider updating to newer version or use thin-websocket wrapper around thin binary.
107
107
 
108
+ ### How to enable debugging?
109
+
110
+ Just use :websocket\_debug => true option when initializing your app.
111
+
108
112
  ### How to enable wss/SSL support?
109
113
 
110
114
  Thin v1.2.8 have --ssl option - just use that! :)
data/example/example.ru CHANGED
@@ -25,7 +25,7 @@ end
25
25
  # use Rack::CommonLogger
26
26
 
27
27
  map '/' do
28
- use MyApp
28
+ use MyApp #, :websocket_debug => true
29
29
 
30
30
  run Rack::File.new(File.expand_path(File.dirname(__FILE__)) + '/html')
31
31
  end
@@ -21,26 +21,26 @@ module Rack
21
21
  if(env['HTTP_CONNECTION'].to_s.downcase == 'upgrade' && env['HTTP_UPGRADE'].to_s.downcase == 'websocket')
22
22
  @env = env
23
23
  socket = env['async.connection']
24
- @connection = Connection.new(self, socket)
25
- @connection.dispatch(env) ? async_response : failure_response
24
+ @conn = Connection.new(self, socket, :debug => !!@options[:websocket_debug])
25
+ @conn.dispatch(env) ? async_response : failure_response
26
26
  elsif @app
27
27
  @app.call(env)
28
28
  else
29
- not_fount_response
29
+ not_found_response
30
30
  end
31
31
  end
32
32
 
33
33
  def close_websocket
34
- if @connection
35
- @connection.close_websocket
34
+ if @conn
35
+ @conn.close_websocket
36
36
  else
37
37
  raise WebSocketError, "WebSocket not opened"
38
38
  end
39
39
  end
40
40
 
41
41
  def send_data(data)
42
- if @connection
43
- @connection.send data
42
+ if @conn
43
+ @conn.send data
44
44
  else
45
45
  raise WebSocketError, "WebSocket not opened"
46
46
  end
@@ -56,7 +56,7 @@ module Rack
56
56
  [ 400, { "Content-Type" => "text/plain" }, [ 'invalid data' ] ]
57
57
  end
58
58
 
59
- def not_fount_response
59
+ def not_found_response
60
60
  [ 404, { "Content-Type" => "text/plain" }, [ 'not found' ] ]
61
61
  end
62
62
 
@@ -65,7 +65,7 @@ module Rack
65
65
  end
66
66
 
67
67
  def dispatch(data)
68
- debug [:inbound_headers, data]
68
+ debug [:inbound_headers, data.inspect]
69
69
  @handler = HandlerFactory.build(self, data, @debug)
70
70
  unless @handler
71
71
  # The whole header has not been received yet.
@@ -2,7 +2,7 @@ require 'rack'
2
2
 
3
3
  module Rack
4
4
  module WebSocket
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  ROOT_PATH = ::File.expand_path(::File.dirname(__FILE__))
7
7
 
8
8
  class WebSocketError < RuntimeError; end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: websocket-rack
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bernard Potocki
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-07 00:00:00 +01:00
18
+ date: 2011-03-08 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency