riddl 0.99.133 → 0.99.134

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,16 +38,6 @@ module Thin #{{{
38
38
  end
39
39
  end #}}}
40
40
 
41
- class WebSocketParserData
42
- attr_accessor :headers, :request_path, :query_string, :http_method, :body, :request_url
43
- def match(what)
44
- @body =~ what
45
- end
46
- def upgrade?
47
- true
48
- end
49
- end
50
-
51
41
  module EventMachine
52
42
  module WebSocket
53
43
  class Handshake
@@ -61,44 +51,56 @@ module EventMachine
61
51
  end
62
52
 
63
53
  module Riddl
64
- class WebSocket < ::EventMachine::WebSocket::Connection
65
- class Error < RuntimeError; end
54
+ module Protocols
55
+ class WebSocket < ::EventMachine::WebSocket::Connection
56
+ class Error < RuntimeError; end
66
57
 
67
- def self.new(*args)
68
- instance = allocate
69
- instance.__send__(:initialize, *args)
70
- instance
71
- end
58
+ class ParserData
59
+ attr_accessor :headers, :request_path, :query_string, :http_method, :body, :request_url
60
+ def match(what)
61
+ @body =~ what
62
+ end
63
+ def upgrade?
64
+ true
65
+ end
66
+ end
72
67
 
73
- def send_data(*args)
74
- EM.next_tick do
75
- @socket.send_data(*args)
76
- end
77
- end
68
+ def self.new(*args)
69
+ instance = allocate
70
+ instance.__send__(:initialize, *args)
71
+ instance
72
+ end
78
73
 
79
- def close_connection(*args)
80
- EM.next_tick do
81
- trigger_on_close
82
- @socket.close_connection(*args)
83
- end
84
- end
74
+ def send_data(*args)
75
+ EM.next_tick do
76
+ @socket.send_data(*args)
77
+ end
78
+ end
85
79
 
86
- def trigger_on_message(msg); @app.onmessage(msg); end
87
- def trigger_on_open(handshake); @closed = false; @app.onopen; end
88
- def trigger_on_close; @closed = true; @app.onclose; end
89
- def trigger_on_error(error); @closed = true; @app.onerror(error); true; end
80
+ def close_connection(*args)
81
+ EM.next_tick do
82
+ trigger_on_close
83
+ @socket.close_connection(*args)
84
+ end
85
+ end
90
86
 
91
- def initialize(app, socket)
92
- @app = app
93
- @socket = socket
94
- @ssl = socket.backend.respond_to?(:ssl?) && socket.backend.ssl?
95
- @closed = true
96
- socket.websocket = self
97
- socket.comm_inactivity_timeout = 0
98
- end
87
+ def trigger_on_message(msg); @app.onmessage(msg); end
88
+ def trigger_on_open(handshake); @closed = false; @app.onopen; end
89
+ def trigger_on_close; @closed = true; @app.onclose; end
90
+ def trigger_on_error(error); @closed = true; @app.onerror(error); true; end
99
91
 
100
- def closed?
101
- @closed
92
+ def initialize(app, socket)
93
+ @app = app
94
+ @socket = socket
95
+ @ssl = socket.backend.respond_to?(:ssl?) && socket.backend.ssl?
96
+ @closed = true
97
+ socket.websocket = self
98
+ socket.comm_inactivity_timeout = 0
99
+ end
100
+
101
+ def closed?
102
+ @closed
103
+ end
102
104
  end
103
105
  end
104
106
  end
@@ -488,7 +488,7 @@ module Riddl
488
488
  def run(what,*args)# {{{
489
489
  return if @riddl_path == ''
490
490
  if what.class == Class && what.superclass == Riddl::WebSocketImplementation
491
- data = WebSocketParserData.new
491
+ data = Riddl::Protocols::WebSocket::ParserData.new
492
492
  data.request_path = @riddl_pinfo
493
493
  data.request_url = @riddl_pinfo + '?' + @riddl_query_string
494
494
  data.query_string = @riddl_query_string
@@ -498,7 +498,7 @@ module Riddl
498
498
  @riddl_headers.map { |key, value| [key.downcase.gsub('_','-'), value] }
499
499
  ]
500
500
  w = what.new(@riddl_info.merge!(:a => args, :version => @riddl_env['HTTP_SEC_WEBSOCKET_VERSION'], :match => matching_path))
501
- w.io = Riddl::WebSocket.new(w, @riddl_env['thin.connection'])
501
+ w.io = Riddl::Protocols::WebSocket.new(w, @riddl_env['thin.connection'])
502
502
  w.io.dispatch(data)
503
503
  end
504
504
  if what.class == Class && what.superclass == Riddl::Implementation
@@ -314,6 +314,7 @@ module Riddl
314
314
 
315
315
  def onclose
316
316
  @handler.key(@key).ws_close() unless @handler.nil?
317
+ @backend.subscriptions[@key].delete
317
318
  end
318
319
  end #}}}
319
320
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "riddl"
3
- s.version = "0.99.133"
3
+ s.version = "0.99.134"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3"
6
6
  s.summary = "restful interface description and declaration language: tools and client/server libs"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.99.133
4
+ version: 0.99.134
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: tools
11
11
  cert_chain: []
12
- date: 2013-12-12 00:00:00.000000000 Z
12
+ date: 2013-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: xml-smart