Class: BasicClient

Inherits:
Object show all
Defined in:
lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/client.rb

Instance Method Summary collapse

Constructor Details

#initializeBasicClient

Returns a new instance of BasicClient.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/client.rb', line 16

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

Instance Method Details

#do_authObject

auth



65
66
67
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/client.rb', line 65

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

#do_connect(args) ⇒ Object

connect <jid> <password>



56
57
58
59
60
61
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/client.rb', line 56

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

#do_helpObject



46
47
48
49
50
51
52
# File 'lib/gems/xmpp4r-0.4/data/doc/xmpp4r/examples/basic/client.rb', line 46

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