Package papyon :: Module client

Module client

source code

Client

This module contains the main class used to login into the MSN Messenger network. The following example demonstrates a simple client.

>>> import papyon
>>>
>>> server = ('messenger.hotmail.com', 1863)
>>> account = ('papyon@hotmail.com', 'papyon is great !')
>>>
>>> client = papyon.Client(server)
>>> client.login(*account)
>>>
>>> if __name__ == "__main__":
...     import gobject
...     import logging
...     logging.basicConfig(level=logging.DEBUG) # allows us to see the protocol debug
...
...     mainloop = gobject.MainLoop()
...     mainloop.run()

This client will try to login, but will probably fail because of the wrong password, so let's enhance this client so that it displays an error if the password was wrong, this will lead us to use the papyon.event interfaces:

>>> import papyon
>>> import papyon.event
>>>
>>> class ClientEventHandler(papyon.event.ClientEventInterface):
...     def on_client_error(self, error_type, error):
...         if error_type == papyon.event.ClientErrorType.AUTHENTICATION:
...             print ""
...             print "********************************************************"
...             print "* You bummer ! you did input a wrong username/password *"
...             print "********************************************************"
...         else:
...             print "ERROR :", error_type, " ->", error
>>>
>>>
>>> server = ('messenger.hotmail.com', 1863)
>>> account = ('papyon@hotmail.com', 'papyon is great !')
>>>
>>> client = papyon.Client(server)
>>> client_events_handler = ClientEventHandler(client)
>>>
>>> client.login(*account)
>>>
>>> if __name__ == "__main__":
...     import gobject
...     import logging
...
...     logging.basicConfig(level=logging.DEBUG) # allows us to see the protocol debug
...
...     mainloop = gobject.MainLoop()
...     mainloop.run()
Classes
  Client
This class provides way to connect to the notification server as well as methods to manage the contact list, and the personnal settings.