Package pyxmpp :: Package jabberd :: Module component :: Class Component
[hide private]

Class Component

source code

Jabber external component ("jabber:component:accept" protocol) interface implementation.

Override this class to build your components.

Instance Methods [hide private]
 
__init__(self, jid=None, secret=None, server=None, port=5347, disco_name=u'PyXMPP based component', disco_category=u'x-service', disco_type=u'x-unknown', keepalive=0)
Initialize a Component object.
source code
 
connect(self)
Establish a connection with the server.
source code
pyxmpp.jabberd.ComponentStream
get_stream(self)
Get the stream of the component in a safe way.
source code
 
disconnect(self)
Disconnect from the server.
source code
socket.socket
socket(self)
Get the socket of the connection to the server.
source code
 
loop(self, timeout=1)
Simple 'main loop' for a component.
source code
 
register_feature(self, feature_name)
Register a feature to be announced by Service Discovery.
source code
 
unregister_feature(self, feature_name)
Unregister a feature to be announced by Service Discovery.
source code
 
__stream_state_change(self, state, arg)
Handle various stream state changes and call right methods of self.
source code
 
__disco_info(self, iq)
Handle a disco-info query.
source code
 
__disco_items(self, iq)
Handle a disco-items query.
source code
 
idle(self)
Do some "housekeeping" work like <iq/> result expiration.
source code
 
stream_created(self, stream)
Handle stream creation event.
source code
 
stream_closed(self, stream)
Handle stream closure event.
source code
 
stream_error(self, err)
Handle a stream error received.
source code
 
stream_state_changed(self, state, arg)
Handle a stream state change.
source code
 
connected(self)
Handle stream connection event.
source code
 
authenticated(self)
Handle successful authentication event.
source code
 
authorized(self)
Handle successful authorization event.
source code
 
disco_get_info(self, node, iq)
Get disco#info data for a node.
source code
 
disco_get_items(self, node, iq)
Get disco#items data for a node.
source code
 
disconnected(self)
Handle stream disconnection (connection closed by peer) event.
source code
Instance Variables [hide private]
str disco_category
disco category to be used to create disco_identity.
pyxmpp.jabber.DiscoIdentity disco_identity
disco identity (part of disco info) announced by the component.
pyxmpp.jabber.DiscoInfo disco_info
disco info announced by the component.
pyxmpp.jabber.DiscoItems disco_items
disco items announced by the component.
str disco_type
disco type to be used to create disco_identity.
pyxmpp.JID jid
component JID (should contain only the domain part).
int keepalive
keepalive interval for the stream.
int port
port number on the server to which the commonent will connect.
unicode secret
the authentication secret.
unicode server
server to which the commonent will connect.
pyxmpp.jabberd.ComponentStream stream
the XMPP stream object for the active connection or None if no connection is active.
Method Details [hide private]

__init__(self, jid=None, secret=None, server=None, port=5347, disco_name=u'PyXMPP based component', disco_category=u'x-service', disco_type=u'x-unknown', keepalive=0)
(Constructor)

source code 
Initialize a Component object.
Parameters:
  • jid (pyxmpp.JID) - component JID (should contain only the domain part).
  • secret (unicode) - the authentication secret.
  • server (str or unicode) - server name or address the component should connect.
  • port (int) - port number on the server where the component should connect.
  • disco_name (unicode) - disco identity name to be used in the disco#info responses.
  • disco_category (unicode) - disco identity category to be used in the disco#info responses. Use the categories registered by Jabber Registrar
  • disco_type (unicode) - disco identity type to be used in the component's disco#info responses. Use the types registered by Jabber Registrar
  • keepalive (int) - keepalive interval for the stream.

connect(self)

source code 

Establish a connection with the server.

Set self.stream to the pyxmpp.jabberd.ComponentStream when initial connection succeeds.

Raises:

get_stream(self)

source code 
Get the stream of the component in a safe way.
Returns: pyxmpp.jabberd.ComponentStream
Stream object for the component or None if no connection is active.

socket(self)

source code 
Get the socket of the connection to the server.
Returns: socket.socket
the socket.

loop(self, timeout=1)

source code 

Simple 'main loop' for a component.

This usually will be replaced by something more sophisticated. E.g. handling of other input sources.

register_feature(self, feature_name)

source code 
Register a feature to be announced by Service Discovery.
Parameters:
  • feature_name (unicode) - feature namespace or name.

unregister_feature(self, feature_name)

source code 
Unregister a feature to be announced by Service Discovery.
Parameters:
  • feature_name (unicode) - feature namespace or name.

__stream_state_change(self, state, arg)

source code 
Handle various stream state changes and call right methods of self.
Parameters:
  • state (string) - state name.
  • arg (any object) - state parameter.

__disco_info(self, iq)

source code 

Handle a disco-info query.

Types:
Parameters:
  • iq - the stanza received.

__disco_items(self, iq)

source code 

Handle a disco-items query.

Types:
Parameters:
  • iq - the stanza received.

idle(self)

source code 
Do some "housekeeping" work like <iq/> result expiration. Should be called on a regular basis, usually when the component is idle.

stream_created(self, stream)

source code 

Handle stream creation event.

[may be overriden in derived classes]

By default: do nothing.

Parameters:

stream_closed(self, stream)

source code 

Handle stream closure event.

[may be overriden in derived classes]

By default: do nothing.

Parameters:

stream_error(self, err)

source code 

Handle a stream error received.

[may be overriden in derived classes]

By default: just log it. The stream will be closed anyway.

Parameters:

stream_state_changed(self, state, arg)

source code 

Handle a stream state change.

[may be overriden in derived classes]

By default: do nothing.

Parameters:
  • state (string) - state name.
  • arg (any object) - state parameter.

connected(self)

source code 

Handle stream connection event.

[may be overriden in derived classes]

By default: do nothing.

authenticated(self)

source code 

Handle successful authentication event.

A good place to register stanza handlers and disco features.

[should be overriden in derived classes]

By default: set disco#info and disco#items handlers.

disco_get_info(self, node, iq)

source code 

Get disco#info data for a node.

[may be overriden in derived classes]

By default: return self.disco_info if no specific node name is provided.

Parameters:
  • node (unicode) - name of the node queried.
  • iq (pyxmpp.Iq) - the stanza received.

disco_get_items(self, node, iq)

source code 

Get disco#items data for a node.

[may be overriden in derived classes]

By default: return self.disco_items if no specific node name is provided.

Parameters:
  • node (unicode) - name of the node queried.
  • iq (pyxmpp.Iq) - the stanza received.

disconnected(self)

source code 

Handle stream disconnection (connection closed by peer) event.

[may be overriden in derived classes]

By default: do nothing.


Instance Variable Details [hide private]

disco_identity

disco identity (part of disco info) announced by the component. Created when a stream is connected.
Type:
pyxmpp.jabber.DiscoIdentity

disco_info

disco info announced by the component. Created when a stream is connected.
Type:
pyxmpp.jabber.DiscoInfo

disco_items

disco items announced by the component. Created when a stream is connected.
Type:
pyxmpp.jabber.DiscoItems