em-xmpp 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/em-xmpp/connection.rb +1 -1
- data/lib/em-xmpp/context.rb +601 -363
- data/lib/em-xmpp/handler.rb +31 -15
- data/lib/em-xmpp/helpers.rb +2 -2
- data/lib/em-xmpp/namespaces.rb +10 -0
- data/lib/em-xmpp/version.rb +1 -1
- data/samples/hello.rb +13 -9
- metadata +8 -8
data/lib/em-xmpp/handler.rb
CHANGED
@@ -29,43 +29,59 @@ module EM::Xmpp
|
|
29
29
|
|
30
30
|
def stack_decorators
|
31
31
|
on_presence_decorator do |ctx|
|
32
|
-
|
33
|
-
ctx
|
32
|
+
presence = ctx.bit!(:presence)
|
33
|
+
ctx.bit!(:error) if presence.error?
|
34
34
|
ctx
|
35
35
|
end
|
36
36
|
on_message_decorator do |ctx|
|
37
|
-
|
38
|
-
ctx
|
37
|
+
msg = ctx.bit!(:message)
|
38
|
+
ctx.bit!(:error) if msg.error?
|
39
39
|
ctx
|
40
40
|
end
|
41
41
|
on_iq_decorator do |ctx|
|
42
|
-
|
43
|
-
ctx
|
42
|
+
iq = ctx.bit!(:iq)
|
43
|
+
ctx.bit!(:error) if iq.error?
|
44
44
|
ctx
|
45
45
|
end
|
46
46
|
on_decorator('//xmlns:delay', 'xmlns' => Delay) do |ctx|
|
47
|
-
ctx.
|
47
|
+
ctx.bit!(:delay)
|
48
|
+
ctx
|
48
49
|
end
|
49
50
|
on_decorator('//xmlns:query', 'xmlns' => DiscoverInfos) do |ctx|
|
50
|
-
ctx.
|
51
|
+
ctx.bit!(:discoinfos)
|
52
|
+
ctx
|
51
53
|
end
|
52
54
|
on_decorator('//xmlns:query', 'xmlns' => DiscoverItems) do |ctx|
|
53
|
-
ctx.
|
55
|
+
ctx.bit!(:discoitems)
|
56
|
+
ctx
|
54
57
|
end
|
55
58
|
on_decorator('//xmlns:query', 'xmlns' => Roster) do |ctx|
|
56
|
-
ctx.
|
59
|
+
ctx.bit!(:roster)
|
60
|
+
ctx
|
57
61
|
end
|
58
62
|
on_decorator('//xmlns:command', 'xmlns' => Commands) do |ctx|
|
59
|
-
ctx.
|
63
|
+
ctx.bit!(:command)
|
64
|
+
ctx
|
60
65
|
end
|
61
66
|
on_decorator('//xmlns:x', 'xmlns' => DataForms) do |ctx|
|
62
|
-
ctx.
|
67
|
+
ctx.bit!(:dataforms)
|
68
|
+
ctx
|
63
69
|
end
|
64
70
|
on_decorator('//xmlns:nick', 'xmlns' => Nick) do |ctx|
|
65
|
-
ctx.
|
71
|
+
ctx.bit!(:nickname)
|
72
|
+
ctx
|
66
73
|
end
|
67
74
|
on_decorator('//xmlns:x', 'xmlns' => MucUser) do |ctx|
|
68
|
-
ctx.
|
75
|
+
ctx.bit!(:mucuser)
|
76
|
+
ctx
|
77
|
+
end
|
78
|
+
on_decorator('//xmlns:si', 'xmlns' => StreamInitiation) do |ctx|
|
79
|
+
ctx.bit!(:streaminitiation)
|
80
|
+
ctx
|
81
|
+
end
|
82
|
+
on_decorator('//xmlns:query', 'xmlns' => ByteStreams) do |ctx|
|
83
|
+
ctx.bit!(:bytestreams)
|
84
|
+
ctx
|
69
85
|
end
|
70
86
|
end
|
71
87
|
|
@@ -326,7 +342,7 @@ module EM::Xmpp
|
|
326
342
|
end
|
327
343
|
|
328
344
|
c.send_stanza(session_request) do |ctx|
|
329
|
-
if ctx.type == 'result'
|
345
|
+
if ctx.bit!(:stanza).type == 'result'
|
330
346
|
@connection.negotiation_finished
|
331
347
|
ctx.delete_xpath_handler!.done!
|
332
348
|
else
|
data/lib/em-xmpp/helpers.rb
CHANGED
data/lib/em-xmpp/namespaces.rb
CHANGED
@@ -45,5 +45,15 @@ module EM::Xmpp
|
|
45
45
|
MucOwner = 'http://jabber.org/protocol/muc#owner'
|
46
46
|
#Multi user chat - roomconfig
|
47
47
|
MucRoomconfig = 'http://jabber.org/protocol/muc#roomconfig'
|
48
|
+
#Stream initiation offer
|
49
|
+
StreamInitiation = 'http://jabber.org/protocol/si'
|
50
|
+
#FileTransfer
|
51
|
+
FileTransfer = 'http://jabber.org/protocol/si/profile/file-transfer'
|
52
|
+
#Feature Negotiation
|
53
|
+
FeatureNeg = 'http://jabber.org/protocol/feature-neg'
|
54
|
+
#ByteStreamTransfer
|
55
|
+
ByteStreams = 'http://jabber.org/protocol/bytestreams'
|
56
|
+
#Extension for Fast byte stream transfers
|
57
|
+
FastByteStreams = 'http://affinix.com/jabber/stream'
|
48
58
|
end
|
49
59
|
end
|
data/lib/em-xmpp/version.rb
CHANGED
data/samples/hello.rb
CHANGED
@@ -19,22 +19,26 @@ module RosterClient
|
|
19
19
|
puts "***** #{@jid} ready"
|
20
20
|
|
21
21
|
on_presence do |ctx|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
presence = ctx.bit(:presence)
|
23
|
+
|
24
|
+
if presence.subscription_request?
|
25
|
+
puts "**** accepting subscription from #{presence.from}"
|
26
|
+
send_stanza presence.reply('type'=>'subscribed')
|
27
|
+
presence.from.subscribe
|
28
|
+
presence.from.add_to_roster
|
27
29
|
else
|
28
|
-
puts "**** #{
|
30
|
+
puts "**** #{presence.from} is present"
|
29
31
|
end
|
30
32
|
|
31
33
|
ctx #returns a ctx for subsequent handlers if any
|
32
34
|
end
|
33
35
|
|
34
36
|
on_message do |ctx|
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
msg = ctx.bit :message
|
38
|
+
|
39
|
+
puts "**** message from #{msg.from}"
|
40
|
+
puts msg.body
|
41
|
+
hello = msg.reply do |rep|
|
38
42
|
rep.body "hello world"
|
39
43
|
end
|
40
44
|
send_stanza hello
|
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.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156077160 !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: *2156077160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156076480 !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: *2156076480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: ruby-sasl
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156075840 !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: *2156075840
|
47
47
|
description: XMPP client for event machine
|
48
48
|
email:
|
49
49
|
- crapooze@gmail.com
|