Class Jabber::Component
In: lib/xmpp4r/component.rb
Parent: Connection
XMLStanza Message Presence Iq REXML::Element X IqQuery Error StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite Feature Identity Item XDataField XDataReported XDataTitle XDataInstructions IqVcard Singleton IdGenerator Connection Client Component Comparable JID RuntimeError ErrorException AuthenticationFailure SOCKS5Error Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryDiscoItems IqQueryDiscoInfo IBB IBBTarget IBBInitiator Responder SimpleResponder X XRoster XMUCUser XMUC XDelay XData MUCClient SimpleMUCClient Base DigestMD5 Plain FileSource StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper MUCBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/stream.rb lib/xmpp4r/client.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/x.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/message.rb lib/xmpp4r/presence.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb Bytestreams lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb lib/xmpp4r/roster/x/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/helper/mucclient.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber Module: Jabber

The component class provides everything needed to build a XMPP Component.

Components are more flexible as they are only restricted in the use of a fixed domain. node and resource of JIDs are freely choosable for all stanzas.

Methods

auth   close   connect   generate_stream_start   new   start  

Attributes

jid  [R]  The component’s JID
server_address  [R]  The server’s address
server_port  [R]  The server’s port

Public Class methods

Create a new Component

jid:[JID]

[Source]

    # File lib/xmpp4r/component.rb, line 26
26:     def initialize(jid, server_address=nil, server_port=5347, threaded = true)
27:       super(threaded)
28:       @jid = (jid.kind_of?(JID) ? jid : JID.new(jid.to_s))
29: 
30:       if server_address
31:         $stderr.puts "Passing server and port to Jabber::Component::new is " +
32:                      "obsolete and will vanish in some later XMPP4R release. " +
33:                      "Please use these arguments when calling " +
34:                      "Jabber::Client#connect"
35:         @server_address = server_address
36:         @server_port = server_port
37:       end
38:     end

Public Instance methods

Send auth with given secret and wait for result

Throws AuthenticationFailure

secret:[String] the shared secret

[Source]

     # File lib/xmpp4r/component.rb, line 85
 85:     def auth(secret)
 86:       hash = Digest::SHA1::new(@streamid.to_s + secret).to_s
 87:       authenticated = false
 88:       send("<handshake>#{hash}</handshake>") { |r|
 89:         if r.prefix == 'stream' and r.name == 'error'
 90:           true
 91:         elsif r.name == 'handshake'
 92:           authenticated = true
 93:           true
 94:         else
 95:           false
 96:         end
 97:       }
 98:       unless authenticated
 99:         raise AuthenticationFailure.new, "Component authentication failed"
100:       end
101:     end

Close the connection, sends </stream:stream> tag first

[Source]

    # File lib/xmpp4r/component.rb, line 57
57:     def close
58:       send("</stream:stream>")
59:       super
60:     end

Connect to the server (chaining-friendly)

server:[String] Hostname
port:[Integer] TCP port (5347)
return:self

[Source]

    # File lib/xmpp4r/component.rb, line 45
45:     def connect(server=nil, port=5347)
46:       if server
47:         super(server, port)
48:       else
49:         super(@server_address, @server_port)
50:       end
51:       self
52:     end

Start the stream-parser and send the component-specific stream opening element

[Source]

    # File lib/xmpp4r/component.rb, line 69
69:     def start
70:       super
71:       send(generate_stream_start(@jid)) { |e|
72:         if e.name == 'stream'
73:           true
74:         else
75:           false
76:         end
77:       }
78:     end

Private Instance methods

[Source]

    # File lib/xmpp4r/component.rb, line 62
62:     def generate_stream_start(to=nil, from=nil, id=nil, xml_lang="en", xmlns="jabber:component:accept", version="1.0")
63:       super
64:     end

[Validate]