em-xmpp 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Em
2
2
  module Xmpp
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-05-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
16
- requirement: &2160613180 !ruby/object:Gem::Requirement
16
+ requirement: &2154840920 !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: *2160613180
24
+ version_requirements: *2154840920
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &2160612760 !ruby/object:Gem::Requirement
27
+ requirement: &2154840500 !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: *2160612760
35
+ version_requirements: *2154840500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ruby-sasl
38
- requirement: &2160612340 !ruby/object:Gem::Requirement
38
+ requirement: &2154840080 !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: *2160612340
46
+ version_requirements: *2154840080
47
47
  description: XMPP client for event machine
48
48
  email:
49
49
  - crapooze@gmail.com
@@ -70,9 +70,6 @@ files:
70
70
  - lib/em-xmpp/stanza_handler.rb
71
71
  - lib/em-xmpp/stanza_matcher.rb
72
72
  - lib/em-xmpp/version.rb
73
- - samples/echo.rb
74
- - samples/muc.rb
75
- - samples/roster.rb
76
73
  homepage: https://github.com/crapooze/em-xmpp
77
74
  licenses: []
78
75
  post_install_message:
data/samples/echo.rb DELETED
@@ -1,72 +0,0 @@
1
-
2
- $LOAD_PATH.unshift './lib'
3
- require 'em-xmpp'
4
- require 'em-xmpp/namespaces'
5
- require 'em-xmpp/nodes'
6
-
7
- if ARGV.empty?
8
- puts "usage: #{__FILE__} <jid> [<pass>]"
9
- exit 0
10
- end
11
-
12
- jid = ARGV.first
13
- pass = ARGV[1]
14
-
15
- include EM::Xmpp::Namespaces
16
- include EM::Xmpp::Nodes
17
-
18
- module MyClient
19
- def ready
20
- puts "***** #{@jid} ready for #{self}"
21
-
22
- # Sending a stanza and adding a temporary matcher to it.
23
- # Returns an handler object that is already ready to process further stanzas.
24
- # Note that so far there is no way to time-out such an handler automatically.
25
- handler = send_stanza(iq_stanza('to'=> 'dicioccio@mbpldc.local') do |x|
26
- x.body "this will trigger an XMPP error"
27
- end) do |ctx|
28
- if ctx.error?
29
- p ctx.error_code
30
- p ctx.error_type
31
- p ctx.error_condition
32
- end
33
- ctx
34
- end
35
-
36
- # Exception handling (i.e., when Ruby raises something)
37
- on_exception(:anything) do |ctx|
38
- raise ctx['error']
39
- end
40
-
41
- # Manually add a matcher + handler for it
42
- m = EM::Xmpp::StanzaMatcher.new do |ctx|
43
- p "proc-ing"
44
- true
45
- end
46
- h = EM::Xmpp::StanzaHandler.new(m) do |ctx|
47
- p "proc-ed"
48
- ctx
49
- end
50
- @handler.add_handler h
51
-
52
- # Presence handler
53
- on_presence do |s|
54
- p "*presence> #{s.from} #{s.show} (#{s.status})"
55
- send_stanza(s.reply('type'=>'subscribed')) if s.subscription_request?
56
- s
57
- end
58
-
59
- # Message handler
60
- on_message do |s|
61
- p "*message> #{s.from}\n#{s.body}\n"
62
- send_stanza(s.reply do |x|
63
- x.body "you sent:#{s.body}"
64
- end)
65
- s
66
- end
67
- end
68
- end
69
-
70
- EM.run do
71
- EM::Xmpp::Connection.start(jid, pass, MyClient)
72
- end
data/samples/muc.rb DELETED
@@ -1,95 +0,0 @@
1
-
2
- $LOAD_PATH.unshift './lib'
3
- require 'em-xmpp'
4
- require 'em-xmpp/namespaces'
5
- require 'em-xmpp/nodes'
6
-
7
- if ARGV.size < 3
8
- puts "usage: #{__FILE__} <jid> <pass> <muc> [<invitees>...]"
9
- exit 0
10
- end
11
-
12
- jid = ARGV.first
13
- pass = ARGV[1]
14
- muc = ARGV[2]
15
- invitees = ARGV[3 .. -1]
16
-
17
- include EM::Xmpp::Namespaces
18
- include EM::Xmpp::Nodes
19
-
20
- module MyClient
21
- def join_muc(muc, login='myclient')
22
- p "joining muc: #{muc}"
23
- muc = [muc, login].join('/')
24
- send_stanza presence_stanza('to'=> muc, 'id' => 'join.muc')
25
- end
26
-
27
- def leave_muc(muc, login='myclient')
28
- p "leaving muc: #{muc}"
29
- muc = [muc, login].join('/')
30
- send_stanza(presence_stanza('to'=> muc, 'id' => 'leave.muc', 'type' => 'unavailable')) do |ctx|
31
- p "left muc"
32
- ctx
33
- end
34
- end
35
-
36
- def invite_to_muc(invitee, muc, text)
37
- p "inviting #{invitee} to #{muc}"
38
- send_stanza(message_stanza('to' => muc, 'type' => 'normal') do |xml|
39
- xml.x(:xmlns => 'http://jabber.org/protocol/muc#user') do |x|
40
- x.invite(:to => invitee) do |invite|
41
- invite.reason do |reason|
42
- reason.text text
43
- end
44
- end
45
- end
46
- end)
47
- end
48
-
49
- attr_accessor :muc
50
- attr_accessor :invitees
51
-
52
- def ready
53
- puts "***** #{@jid} ready for #{self}"
54
-
55
- join_muc(muc)
56
-
57
- on('//xmlns:x', 'xmlns' => EM::Xmpp::Namespaces::MucUser) do |ctx|
58
- muc = ctx.jid.bare if ctx.jid
59
- p ctx.jid
60
- p ctx.affiliation
61
- p ctx.role
62
- if ctx.status
63
- invitees.each do |invitee|
64
- p invitee
65
- invite_to_muc muc, invitee, "hello, join my MUC"
66
- end
67
- end
68
- ctx
69
- end
70
-
71
- on_message do |ctx|
72
- p "message"
73
- p ctx.nickname if ctx.respond_to?(:nickname)
74
- leave_muc(muc) if ctx.body =~ /leave/ and not ctx.delay?
75
- ctx
76
- end
77
-
78
- on_exception(:anything) do |ctx|
79
- raise ctx['error']
80
- end
81
-
82
- on_presence do |s|
83
- p "*presence> #{s.from} #{s.show} (#{s.status})"
84
- p " has left" if s.entity_left?
85
- s
86
- end
87
-
88
- end
89
- end
90
-
91
- EM.run do
92
- conn = EM::Xmpp::Connection.start(jid, pass, MyClient)
93
- conn.muc = muc
94
- conn.invitees = invitees
95
- end
data/samples/roster.rb DELETED
@@ -1,41 +0,0 @@
1
-
2
-
3
- $LOAD_PATH.unshift './lib'
4
- require 'em-xmpp'
5
- require 'em-xmpp/namespaces'
6
- require 'em-xmpp/nodes'
7
-
8
- if ARGV.empty?
9
- puts "usage: #{__FILE__} <jid> [<pass>]"
10
- exit 0
11
- end
12
-
13
- jid = ARGV.first
14
- pass = ARGV[1]
15
-
16
- include EM::Xmpp::Namespaces
17
- include EM::Xmpp::Nodes
18
-
19
- module MyClient
20
- def ask_roster
21
- send_stanza(iq_stanza do |x|
22
- x.query('xmlns' => Roster)
23
- end) do |ctx|
24
- p ctx.items
25
- ctx
26
- end
27
- end
28
-
29
- def ready
30
- puts "***** #{@jid} ready for #{self}"
31
- on_exception(:anything) do |ctx|
32
- raise ctx['error']
33
- end
34
-
35
- ask_roster
36
- end
37
- end
38
-
39
- EM.run do
40
- EM::Xmpp::Connection.start(jid, pass, MyClient)
41
- end