register – Register class handler

Module author: Sylvain Hellegouarch <sh@defuze.org>

Register class handler

Basic usage

To register a new user you can simply create an instance of the Register class.

>>> from headstock.client import AsyncClient
>>> c = AsyncClient(u'user@domain', u'secret', hostname='localhost', port=5222, registerclass=Register)
>>> c.set_log(stdout=True)
>>> c.run()

You will not have much control over the XMPP exchange.

More control over the registration process

When you want to react at what happens during the XMPP exchange, you should subclass the Register class and implement:

handle_register_success(e)
handle_register_conflict(e)
handle_resource_constraint(e)

Register class

class headstock.register.Register(client, username, password, email=None)

Default class to register a user. This will perform the actual register exchange.

client headstock.client.BaseClient instance

username username expected to be registered

password chosen password for the account

email None - account’s email

handle_register_conflict(e)

Called when the username is already used on the server.

Does nothing by default.

e bridge.Element instance representing the dispatched stanza

handle_register_success(e)

Handler called when the server replies a IQ stanza indicating the registration succeeded.

Does nothing by default.

e bridge.Element instance representing the dispatched stanza

handle_registration(e)

Handler called when the server sends the registration form and returns the same form filled with at least the username and password.

e bridge.Element instance representing the dispatched stanza

handle_resource_constraint(e)

Called when the server limits the resources it allows to this connection.

Raises a headstock.error.HeadstockStreamError instance.

e bridge.Element instance representing the dispatched stanza

register(e)

Handler called when the <register xmlns=”http://jabber.org/features/iq-register” /> stanza is received and the client required the registration process.

Returns a stanza indicating the client is indeed requesting the registration process from the server.

e bridge.Element instance representing the dispatched stanza

Table Of Contents

Previous topic

client – XMPP client

Next topic

stream – Stream class handler

This Page