wampus 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14ca9589d293012e05857f4bae923a158b794099
4
- data.tar.gz: a4da144a3fbf35345d47b75d56ebcd9a9b715c66
3
+ metadata.gz: 64e79cb9e7b99c33ed789828ebe831a943f1613e
4
+ data.tar.gz: ebaae0ad6da9e25be70144855b23e3a5d352125c
5
5
  SHA512:
6
- metadata.gz: bde24c014aa16619a31a9c591df246b4782884586009c02971dfe8dd4c9c6744f745825524e06e0c3175adcd480dccbc4f5ac1eac3225fedcb421758dac437bd
7
- data.tar.gz: 7b049c53ba81457f85279a43991b6b8044a961363aacf662aae9203d5f93ee2d5dc5069ea98898ecb6ecc12644ee2a8e6c2937acbfcb1e99a771739704358667
6
+ metadata.gz: 071a2bd09533edf1719c350245781206639fa919319e6306fa3d69eccebd5b7252e128805b2fff0c7d9f7fe6bb359a78c8afca03b78dcecc91c5e29a0e331c62
7
+ data.tar.gz: 1b84d5f9be5b1606dbc863efc2b0c1babfc47326e650edccc8f7c0b877826c873066a26bd5cc25d75126f15afdcfe4aa944d3398e0d2b812375e2ec9718c1af0
@@ -1,3 +1,6 @@
1
+ require 'active_support/concern'
2
+ require 'active_support/core_ext/class/attribute'
3
+
1
4
  module Wampus
2
5
  module AfterInit
3
6
  extend ActiveSupport::Concern
@@ -1,3 +1,6 @@
1
+ require 'active_support/concern'
2
+ require 'active_support/core_ext/class/attribute'
3
+
1
4
  module Wampus
2
5
  module Backends
3
6
  module Redis
@@ -84,7 +87,7 @@ module Wampus
84
87
 
85
88
  topic.subscribers(connection, excluded, included) do |subscribers|
86
89
  subscribers.each do |connection|
87
- connection.websocket.send event_msg(topic.uri, payload)
90
+ connection.write event_msg(topic.uri, payload)
88
91
  end
89
92
  end
90
93
  rescue => error
@@ -12,10 +12,14 @@ module Wampus
12
12
  @topics = []
13
13
 
14
14
  @authenticated = false
15
- @pending_auth = nil,
15
+ @pending_auth = nil
16
16
  @auth_timeout_call = nil
17
17
  end
18
18
 
19
+ def write(msg)
20
+ @websocket.send msg
21
+ end
22
+
19
23
  def subscribe_to_topic(topic)
20
24
  @topics << topic
21
25
  end
@@ -7,7 +7,7 @@ module Wampus
7
7
 
8
8
  include Wamp
9
9
 
10
- URI_PROCEDURE = URI_BASE + 'procedure#'
10
+ URI_PROCEDURE = Wampus::Protocols::Wamp::URI_BASE + 'procedure#'
11
11
 
12
12
  def derive_key(secret, extra = nil)
13
13
  if extra.is_a?(Hash) && extra.has_key?(:salt)
@@ -1,3 +1,6 @@
1
+ require 'active_support/concern'
2
+ require 'active_support/core_ext/class/attribute'
3
+
1
4
  module Wampus
2
5
  module Pubsub
3
6
  module Handler
@@ -1,3 +1,5 @@
1
+ require 'active_support/concern'
2
+
1
3
  module Wampus
2
4
  module Pubsub
3
5
  module ServerExt
@@ -82,7 +84,7 @@ module Wampus
82
84
  else
83
85
  begin
84
86
  if handler[2]
85
- result = handler[2].send handler[3], [connection, topic_uri]
87
+ result = handler[2].send handler[3], connection, topic_uri
86
88
  elsif handler[3].is_a? Proc
87
89
  result = handler[3].call connection, topic_uri
88
90
  end
@@ -122,12 +124,13 @@ module Wampus
122
124
  begin
123
125
  begin
124
126
  if handler[2]
125
- result = handler[2].send handler[3], [connection, topic_uri]
127
+ result = handler[2].send handler[3], [connection, topic_uri, event]
126
128
  elsif handler[3].is_a? Proc
127
- result = handler[1].call connection, topic_uri
129
+ result = handler[3].call connection, topic_uri, event
128
130
  end
129
131
  dispatch_event topic.uri, event, exclude, include
130
132
  rescue => error
133
+ puts error.message
131
134
  # Nothing
132
135
  end
133
136
  end
@@ -137,7 +140,7 @@ module Wampus
137
140
  def dispatch_event(topic_uri, event, exclude, include)
138
141
  topic = topics[topic_uri]
139
142
  topic.subscribers(exclude, include).each do |subscriber|
140
- subscriber.websocket.send event_msg(topic_uri, event)
143
+ subscriber.write event_msg(topic_uri, event)
141
144
  end
142
145
  end
143
146
 
@@ -1,3 +1,6 @@
1
+ require 'active_support/concern'
2
+ require 'active_support/core_ext/class/attribute'
3
+
1
4
  module Wampus
2
5
  module Rpc
3
6
  module Handler
@@ -1,3 +1,5 @@
1
+ require 'active_support/concern'
2
+
1
3
  module Wampus
2
4
  module Rpc
3
5
  module ServerExt
@@ -19,7 +21,7 @@ module Wampus
19
21
  def register_rpc_handler(handler, base_uri)
20
22
  after_init do
21
23
  handler.rpc_handlers.each do |procedure, handler_method|
22
- uri = URI_RPC_BASE + procedure
24
+ uri = Wampus::Protocols::Wamp::URI_RPC + procedure
23
25
  register_rpc_method uri, handler, handler_method
24
26
  end
25
27
  end
@@ -49,19 +51,19 @@ module Wampus
49
51
  rpc_call_exists = rpcs.has_key?(uri)
50
52
  uri, args = on_before_call connection, call_id, uri, args, rpc_call_exists
51
53
  unless rpc_call_exists
52
- raise Wampus::Errors::CallError.new(URI_ERROR+'NoSuchRPCEndpoint', 'Missing Method')
54
+ raise Wampus::Errors::CallError.new(Wampus::Protocols::Wamp::URI_ERROR+'NoSuchRPCEndpoint', 'Missing Method')
53
55
  end
54
56
  if handler[0]
55
- result = handler[0].send handler[1], [connection, *args]
57
+ result = handler[0].send handler[1], connection, call_id, *args
56
58
  elsif handler[1].is_a? Proc
57
- result = handler[1].call connection, *args
59
+ result = handler[1].call connection, call_id, *args
58
60
  end
59
61
  result = on_after_call_success connection, result
60
- connection.send call_result_msg call_id, result
62
+ connection.write call_result_msg call_id, result
61
63
  rescue => error
62
64
  error = on_after_call_error connection, error
63
65
  msg = call_error_msg call_id, *error.to_call_error
64
- connection.send msg
66
+ connection.write msg
65
67
  on_after_send_call_error connection, msg
66
68
  end
67
69
  end
@@ -78,7 +80,7 @@ module Wampus
78
80
 
79
81
  def on_after_call_error(connection, error)
80
82
  unless error.is_a? Wampus::Errors::CallError
81
- error = Wampus::Errors::CallError.new(URI_ERROR+'generic', 'RPC Call Error')
83
+ error = Wampus::Errors::CallError.new(Wampus::Protocols::Wamp::URI_ERROR+'generic', 'RPC Call Error')
82
84
  end
83
85
  error
84
86
  end
@@ -29,7 +29,7 @@ module Wampus
29
29
 
30
30
  def on_connection_open(websocket, handshake)
31
31
  connection = new_connection(websocket)
32
- connection.websocket.send welcome_msg connection.id
32
+ connection.write welcome_msg connection.id
33
33
  on_session_open connection
34
34
  end
35
35
 
@@ -9,8 +9,8 @@ module Wampus
9
9
  self.client_auth_allow_anonymous = true
10
10
 
11
11
  after_init do
12
- register_rpc_method URI_RPC+'authRequest', self, :auth_request
13
- register_rpc_method URI_RPC+'auth', self, :auth
12
+ register_rpc_method Wampus::Protocols::WampCra::URI_PROCEDURE+'authRequest', self, :auth_request
13
+ register_rpc_method Wampus::Protocols::WampCra::URI_PROCEDURE+'auth', self, :auth
14
14
  end
15
15
 
16
16
  def get_auth_permissions(connection, auth_key, auth_extra)
@@ -39,39 +39,39 @@ module Wampus
39
39
 
40
40
  def auth_request(connection, auth_key = nil, extra = {})
41
41
  if connection.authenticated
42
- raise Wampus::Errors::CallError.new(URI_ERROR+'already-authenticated', 'Already Authenticated')
42
+ raise Wampus::Errors::CallError.new(Wampus::Protocols::Wamp::URI_ERROR+'already-authenticated', 'Already Authenticated')
43
43
  end
44
44
 
45
45
  unless connection.pending_auth.nil?
46
- raise Wampus::Errors::CallError.new(URI_ERROR+'authentication-already-requested', 'Authentication Already Requested')
46
+ raise Wampus::Errors::CallError.new(Wampus::Protocols::Wamp::URI_ERROR+'authentication-already-requested', 'Authentication Already Requested')
47
47
  end
48
48
 
49
49
  unless extra.is_a? Hash
50
- raise Wampus::Errors::CallError.new(URI_ERROR+'invalid-argument', 'Extra is not a Dictionary/Hash')
50
+ raise Wampus::Errors::CallError.new(Wampus::Protocols::Wamp::URI_ERROR+'invalid-argument', 'Extra is not a Dictionary/Hash')
51
51
  end
52
52
 
53
53
  if auth_key.nil? && !client_auth_allow_anonymous
54
- raise Wampus::Errors::CallError.new(URI_ERROR+'anonymous-auth-forbidden', 'Anonymous Auth Forbidden')
54
+ raise Wampus::Errors::CallError.new(Wampus::Protocols::Wamp::URI_ERROR+'anonymous-auth-forbidden', 'Anonymous Auth Forbidden')
55
55
  end
56
56
 
57
57
  auth_secret = get_auth_secret connection, auth_key
58
- on_get_auth_secrek_ok connection, auth_secret, auth_key, extra
58
+ on_get_auth_secret_ok connection, auth_secret, auth_key, extra
59
59
  end
60
60
 
61
61
  def auth(connection, signature = nil)
62
62
  if connection.authenticated
63
- raise Wampus::Errors::CallError.new(URI_ERROR+'already-authenticated', 'Already Authenticated')
63
+ raise Wampus::Errors::CallError.new(Wampus::Protocols::Wamp::URI_ERROR+'already-authenticated', 'Already Authenticated')
64
64
  end
65
65
 
66
66
  if connection.pending_auth.nil?
67
- raise Wampus::Errors::CallError.new(URI_ERROR+'no-authentication-requested', 'No Authentication Requested')
67
+ raise Wampus::Errors::CallError.new(Wampus::Protocols::Wamp::URI_ERROR+'no-authentication-requested', 'No Authentication Requested')
68
68
  end
69
69
 
70
70
  if connection.pending_auth[1] != signature
71
71
  connection.pending_auth = nil
72
72
 
73
73
  return EventMachine.add_timer expo(1.25) {
74
- raise Wampus::Errors::CallError.new URI_ERROR+'invalid-signature', 'Signature for authentication request is invalid'
74
+ raise Wampus::Errors::CallError.new Wampus::Protocols::Wamp::URI_ERROR+'invalid-signature', 'Signature for authentication request is invalid'
75
75
  }
76
76
  end
77
77
 
@@ -115,7 +115,7 @@ module Wampus
115
115
  return nil
116
116
  end
117
117
  rescue => error
118
- raise CallError.new(URI_ERROR+'auth-permissions-error', error.message)
118
+ raise Wampus::Errors::CallError.new(Wampus::Protocols::Wamp::URI_ERROR+'auth-permissions-error', error.message)
119
119
  end
120
120
 
121
121
  def expo(l)
@@ -1,3 +1,3 @@
1
1
  module Wampus
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wampus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Stack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-09 00:00:00.000000000 Z
11
+ date: 2013-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler