Sha256: 70306013bc9f107afd6d230f0de0bb2c324a9b76fb7e8d5e92eeab20927062cb

Contents?: true

Size: 1.29 KB

Versions: 27

Compression:

Stored size: 1.29 KB

Contents

#!/usr/bin/ruby

# Basic console client that does nothing, but easy to modify to test things.
# to test, start, then type :
# connect login@server/resource password
# auth

$:.unshift '../../../../../lib'

require 'xmpp4r/client'
include Jabber

Jabber::debug = true

class BasicClient
  def initialize
    puts "Welcome to this Basic Console Jabber Client!"
    quit = false
    # main loop
    while not quit do
      print "> "
      $defout.flush
      line = gets
      quit = true if line.nil?
      if not quit
        command, args = line.split(' ', 2)
        args = args.to_s.chomp
        # main case
        case command
        when 'exit'
          quit = true
        when 'connect'
          do_connect(args)
        when 'help'
          do_help
        when 'auth'
          do_auth
        else
          puts "Command \"#{command}\" unknown"
        end
      end
    end
    puts "Goodbye!"
  end

  def do_help
    puts <<-EOF
# exit - exits
# connect user@server/resource password - connects
# auth - sends authentification
    EOF
  end

  ##
  # connect <jid> <password>
  def do_connect(args)
    @jid, @password = args.split(' ', 2)
    @jid = JID.new(@jid)
    @cl = Client.new(@jid)
    @cl.connect
  end

  ##
  # auth
  def do_auth
    @cl.auth(@password, false)
  end
end

BasicClient.new

Version data entries

27 entries across 27 versions & 10 rubygems

Version Path
brontes3d-xmpp4r-0.4 data/doc/xmpp4r/examples/basic/client.rb
edavey-xmpp4r-0.4.1 data/doc/xmpp4r/examples/basic/client.rb
edavey-xmpp4r-0.4.2 data/doc/xmpp4r/examples/basic/client.rb
edavey-xmpp4r-0.4 data/doc/xmpp4r/examples/basic/client.rb
ln-xmpp4r-0.5 data/doc/xmpp4r/examples/basic/client.rb
mojodna-xmpp4r-0.4.0.2 data/doc/xmpp4r/examples/basic/client.rb
mojodna-xmpp4r-0.4.0.3 data/doc/xmpp4r/examples/basic/client.rb
seanohalpin-xmpp4r-0.4.1 data/doc/xmpp4r/examples/basic/client.rb
xmpp4r-0.5.5 data/doc/xmpp4r/examples/basic/client.rb
mad-p-xmpp4r-0.6.3 data/doc/xmpp4r/examples/basic/client.rb
mad-p-xmpp4r-0.6.2 data/doc/xmpp4r/examples/basic/client.rb
mad-p-xmpp4r-0.6.1 data/doc/xmpp4r/examples/basic/client.rb
mad-p-xmpp4r-0.6.0 data/doc/xmpp4r/examples/basic/client.rb
cerberus-0.8.0 lib/vendor/xmpp4r/data/doc/xmpp4r/examples/basic/client.rb
cerberus-0.7.9 lib/vendor/xmpp4r/data/doc/xmpp4r/examples/basic/client.rb
edavis10-cerberus-0.7.8 lib/vendor/xmpp4r/data/doc/xmpp4r/examples/basic/client.rb
cerberus-0.7.8 lib/vendor/xmpp4r/data/doc/xmpp4r/examples/basic/client.rb
cerberus-0.7.7 lib/vendor/xmpp4r/data/doc/xmpp4r/examples/basic/client.rb
cerberus-0.7.6 lib/vendor/xmpp4r/data/doc/xmpp4r/examples/basic/client.rb
cerberus-0.7.2 lib/vendor/xmpp4r/data/doc/xmpp4r/examples/basic/client.rb