class Blather::DSL::MultiUserChat

Public Class Methods

new(client, jid, nickname = nil, password = nil) click to toggle source
# File lib/gxg/net_clients.rb, line 47
def initialize(client, jid, nickname = nil, password = nil)
  @client   = client
  @room     = ::Blather::JID.new(jid)
  @nickname = nickname || @room.resource
  @password = password
  @room.strip!
end

Public Instance Methods

configuration(&block)
Alias for: get_configuration
configuration=(values, &block)
Alias for: set_configuration
destroy(reason = nil) click to toggle source

<iq from='crone1@shakespeare.lit/desktop'

  id='begone'
  to='heath@chat.shakespeare.lit'
  type='set'>
<query xmlns='http://jabber.org/protocol/muc#owner'>
  <destroy jid='darkcave@chat.shakespeare.lit'>
    <reason>Macbeth doth come.</reason>
  </destroy>
</query>

</iq>

# File lib/gxg/net_clients.rb, line 120
def destroy(reason = nil)
  destroy = ::Blather::MUC::Owner::Destroy.new(@room)
  
  destroy.reason = reason
  write destroy
end
get_configuration() { |stana| ... } click to toggle source
# File lib/gxg/net_clients.rb, line 127
def get_configuration(&block)
  get_configure = ::Blather::MUC::Owner::Configure.new(:get, @room)
  write_with_handler(get_configure) do |stana|
    yield stana
  end
end
Also aliased as: configuration
invite(jid, reason = nil) click to toggle source

<message to='room@service'>

<x xmlns='http://jabber.org/protocol/muc#user'>
  <invite to='jid'>
    <reason>comment</reason>
  </invite>
</x>

</message>

# File lib/gxg/net_clients.rb, line 81
def invite(jid, reason = nil)
  message = ::Blather::Stanza::Message.new(@room, nil, nil)
  message << ::Blather::MUC::Invite.new(jid, reason, @password)
  
  write message
end
join(reason = nil) click to toggle source
# File lib/gxg/net_clients.rb, line 55
def join(reason = nil)
  join          = ::Blather::Stanza::Presence::MUCJoin.new
  join.to       = "#{@room}/#{@nickname}"
  join.password = @password
  write join
end
leave() click to toggle source
# File lib/gxg/net_clients.rb, line 106
def leave
  self.status = :unavailable
end
members(&block) click to toggle source

<iq from='crone1@shakespeare.lit/desktop'

  id='member3'
  to='darkcave@chat.shakespeare.lit'
  type='get'>
<query xmlns='http://jabber.org/protocol/muc#admin'>
  <item affiliation='member'/>
</query>

</iq>

<iq from='darkcave@chat.shakespeare.lit'

  id='member3'
  to='crone1@shakespeare.lit/desktop'
  type='result'>
<query xmlns='http://jabber.org/protocol/muc#admin'>
  <item affiliation='member'
        jid='hag66@shakespeare.lit'
        nick='thirdwitch'
        role='participant'/>
</query>

</iq>

# File lib/gxg/net_clients.rb, line 173
def members(&block)
  members = ::Blather::MUC::Admin::Members.new(@room)
  
  write_with_handler(members, &block)
end
say(msg, xhtml = nil) click to toggle source

<message to='room@service' type='groupchat'>

<body>foo</body>

</message>

# File lib/gxg/net_clients.rb, line 91
def say(msg, xhtml = nil)
  message = ::Blather::Stanza::Message.new(@room, msg, :groupchat)
  message.xhtml = xhtml if xhtml
  write message
end
set_configuration(values, &block) click to toggle source
# File lib/gxg/net_clients.rb, line 135
def set_configuration(values, &block)
  set_configure = ::Blather::MUC::Owner::Configure.new(:set, @room)
  set_configure.data = values
  write_with_handler(set_configure, &block)
end
Also aliased as: configuration=
set_default_configuration() { || ... } click to toggle source
<iq type='set' id='purple52b37aa2' to='test3@conference.macbook.local'>
 <query xmlns='http://jabber.org/protocol/muc#owner'>
 <x xmlns='jabber:x:data' type='submit'/></query>

</iq>

# File lib/gxg/net_clients.rb, line 146
def set_default_configuration(&block)
  set_configuration(:default) do
    yield if block_given?
  end
end
Also aliased as: unlock
status=(state) click to toggle source

<presence

  from='wiccarocks@shakespeare.lit/laptop'
  to='darkcave@chat.shakespeare.lit/oldhag'>
<show>available</show>

</presence>

# File lib/gxg/net_clients.rb, line 67
def status=(state)
  status       = ::Blather::Stanza::Presence::Status.new
  status.state = state
  status.to    = @room
  write status
end
subject=(body) click to toggle source

<message to='room@service' type='groupchat'>

<subject>foo</subject>

</message>

# File lib/gxg/net_clients.rb, line 100
def subject=(body)
  message = Blather::Stanza::Message.new(@room, nil, :groupchat)
  message.subject = body
  write message
end
unlock(&block)
write(stanza) click to toggle source
# File lib/gxg/net_clients.rb, line 179
def write(stanza)
  @client.write(stanza)
end
write_with_handler(stanza, &block) click to toggle source
# File lib/gxg/net_clients.rb, line 183
def write_with_handler(stanza, &block)
  @client.write_with_handler(stanza, &block)
end