em-xmpp 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em-xmpp/connection.rb +2 -1
- data/lib/em-xmpp/entity.rb +1 -0
- data/lib/em-xmpp/handler.rb +17 -9
- data/lib/em-xmpp/stanza_handler.rb +1 -9
- data/lib/em-xmpp/version.rb +1 -1
- metadata +7 -7
data/lib/em-xmpp/connection.rb
CHANGED
@@ -13,13 +13,14 @@ module EM::Xmpp
|
|
13
13
|
include Namespaces
|
14
14
|
include Connector
|
15
15
|
|
16
|
-
attr_reader :jid, :pass
|
16
|
+
attr_reader :jid, :pass, :user_data
|
17
17
|
|
18
18
|
def initialize(jid, pass, mod=nil, cfg={})
|
19
19
|
@jid = jid
|
20
20
|
@pass = pass.dup.freeze
|
21
21
|
self.extend mod if mod
|
22
22
|
certdir = cfg[:certificates]
|
23
|
+
@user_data = cfg[:data]
|
23
24
|
@certstore = if certdir
|
24
25
|
CertStore.new(certdir)
|
25
26
|
else
|
data/lib/em-xmpp/entity.rb
CHANGED
data/lib/em-xmpp/handler.rb
CHANGED
@@ -89,16 +89,19 @@ module EM::Xmpp
|
|
89
89
|
@exception_handlers.delete handler
|
90
90
|
end
|
91
91
|
|
92
|
-
def
|
92
|
+
def handler_for(path,args,&blk)
|
93
93
|
matcher = StanzaMatcher.new(path, args)
|
94
94
|
handler = StanzaHandler.new(matcher, blk)
|
95
|
+
end
|
96
|
+
|
97
|
+
def on(path, args={}, &blk)
|
98
|
+
handler = handler_for path, args, &blk
|
95
99
|
add_handler handler
|
96
100
|
handler
|
97
101
|
end
|
98
102
|
|
99
103
|
def on_exception(path, args={}, &blk)
|
100
|
-
|
101
|
-
handler = StanzaHandler.new(matcher, &blk)
|
104
|
+
handler = handler_for path, args, &blk
|
102
105
|
add_exception_handler handler
|
103
106
|
handler
|
104
107
|
end
|
@@ -119,18 +122,23 @@ module EM::Xmpp
|
|
119
122
|
# handlers such as request/responses
|
120
123
|
def handle_context(ctx)
|
121
124
|
catch :halt do
|
122
|
-
|
125
|
+
run_xpath_handlers ctx, @handlers.dup, :remove_handler
|
123
126
|
end
|
124
127
|
rescue => err
|
125
128
|
ctx['error'] = err
|
126
|
-
|
129
|
+
run_xpath_handlers ctx, @exception_handlers, :remove_exception_handler
|
127
130
|
end
|
128
131
|
|
129
132
|
# runs all handlers and returns a list of handlers for the next stanza
|
130
|
-
def run_xpath_handlers(ctx, handlers)
|
131
|
-
handlers.
|
132
|
-
|
133
|
-
|
133
|
+
def run_xpath_handlers(ctx, handlers, remover)
|
134
|
+
handlers.each do |h|
|
135
|
+
if (not ctx.done?) and (h.match?(ctx.stanza))
|
136
|
+
ctx['xpath.handler'] = h
|
137
|
+
ctx = h.call(ctx)
|
138
|
+
raise RuntimeError, "xpath handlers should return a Context" unless ctx.is_a?(Context)
|
139
|
+
send remover, h unless ctx.reuse_handler?
|
140
|
+
end
|
141
|
+
end
|
134
142
|
end
|
135
143
|
end
|
136
144
|
|
@@ -13,15 +13,7 @@ module EM::Xmpp
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call(ctx)
|
16
|
-
|
17
|
-
ctx['xpath.handler'] = self
|
18
|
-
ctx = callback.call(ctx)
|
19
|
-
raise RuntimeError, "xpath handlers should return a Context" unless ctx.is_a?(Context)
|
20
|
-
|
21
|
-
self if ctx.reuse_handler?
|
22
|
-
else
|
23
|
-
self
|
24
|
-
end
|
16
|
+
callback.call(ctx)
|
25
17
|
end
|
26
18
|
end
|
27
19
|
end
|
data/lib/em-xmpp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-xmpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-08-25 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
16
|
-
requirement: &
|
16
|
+
requirement: &2155062040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2155062040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &2155061620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2155061620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: ruby-sasl
|
38
|
-
requirement: &
|
38
|
+
requirement: &2155061200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2155061200
|
47
47
|
description: XMPP client for event machine
|
48
48
|
email:
|
49
49
|
- crapooze@gmail.com
|