Sha256: 9772c8c6e6d07c6092a8c8ce9a3acd7139cdfbd155d0dc8a0aa63fc8b8072173

Contents?: true

Size: 650 Bytes

Versions: 32

Compression:

Stored size: 650 Bytes

Contents

require 'blather/client/dsl'
$stdout.sync = true

module Ping
  extend Blather::DSL
  def self.run; client.run; end

  setup 'echo@jabber.local/ping', 'echo'

  status :from => Blather::JID.new('echo@jabber.local/pong') do |s|
    puts "serve!"
    say s.from, 'ping'
  end

  message :chat?, :body => 'pong' do |m|
    puts "ping!"
    say m.from, 'ping'
  end
end

module Pong
  extend Blather::DSL
  def self.run; client.run; end

  setup 'echo@jabber.local/pong', 'echo'
  message :chat?, :body => 'ping' do |m|
    puts "pong!"
    say m.from, 'pong'
  end
end

trap(:INT) { EM.stop }
trap(:TERM) { EM.stop }
EM.run do
  Ping.run
  Pong.run
end

Version data entries

32 entries across 32 versions & 3 rubygems

Version Path
sprsquish-blather-0.3.1 examples/ping_pong.rb
sprsquish-blather-0.3.2 examples/ping_pong.rb
sprsquish-blather-0.3.3 examples/ping_pong.rb
sprsquish-blather-0.3.4 examples/ping_pong.rb
sprsquish-blather-0.4.0 examples/ping_pong.rb
sprsquish-blather-0.4.1 examples/ping_pong.rb
sprsquish-blather-0.4.2 examples/ping_pong.rb
sprsquish-blather-0.4.3 examples/ping_pong.rb
sprsquish-blather-0.4.4 examples/ping_pong.rb
blather-0.4.16 examples/ping_pong.rb
blather-0.4.15 examples/ping_pong.rb
shingara-blather-0.4.14 examples/ping_pong.rb
blather-0.4.14 examples/ping_pong.rb
blather-0.4.13 examples/ping_pong.rb
blather-0.4.12 examples/ping_pong.rb
blather-0.4.11 examples/ping_pong.rb
blather-0.4.10 examples/ping_pong.rb
shingara-blather-0.4.9 examples/ping_pong.rb
shingara-blather-0.4.8 examples/ping_pong.rb
blather-0.4.8 examples/ping_pong.rb