Class: Switchboard::Client

Inherits:
Core
  • Object
show all
Defined in:
lib/switchboard/client.rb

Instance Attribute Summary collapse

Attributes inherited from Core

#jacks, #settings

Instance Method Summary collapse

Methods inherited from Core

#defer, hook, #hook, #plug!, #ready?, #run!

Constructor Details

#initialize(settings = Switchboard::Settings.new, spin = true) ⇒ Client

Returns a new instance of Client.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/switchboard/client.rb', line 5

def initialize(settings = Switchboard::Settings.new, spin = true)
  super(settings, spin)

  # TODO jid may already have a resource, so account for that
  @client = Jabber::Client.new([settings["jid"], settings["resource"]] * "/")

  on_stream_connected do
    register_roster_callbacks

    # tell others that we're online
    presence

    defer :roster_loaded do
      # wait for the roster to load
      roster.wait_for_roster

      # roster has now been loaded
      on(:roster_loaded)
    end
  end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/switchboard/client.rb', line 3

def client
  @client
end

#rosterObject (readonly)

Returns the value of attribute roster.



3
4
5
# File 'lib/switchboard/client.rb', line 3

def roster
  @roster
end