Sha256: 23d977d2d784788b9f2321d70b4b3f9325c2aa40f6910af29658f100ce0e88a8

Contents?: true

Size: 669 Bytes

Versions: 26

Compression:

Stored size: 669 Bytes

Contents

require 'rubygems'
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

26 entries across 26 versions & 2 rubygems

Version Path
blather-0.5.7 examples/ping_pong.rb
blather-0.5.6 examples/ping_pong.rb
blather-0.5.4 examples/ping_pong.rb
blather-0.5.3 examples/ping_pong.rb
blather-0.5.2 examples/ping_pong.rb
blather-0.5.0 examples/ping_pong.rb