AIM ClientDeals with post-login messages from the AIM server, mostly by parsing them and sending them out to its "heard" outbox in a slightly more useable form. Also sends messages to the server based on commands coming through its "talk" inbox. How it works:ChatManager expects to receive FLAPs containing SNACs through its "inbox". It recognizes certain types of SNACs. For these SNACS, ChatManager parses them, and sends the relevant data out to its "heard" outbox in tuple format. The following lists the SNACs ChatManager understands and the tuples that it consequently sends out:
The "buddy online" message contains a dictionary instead of just a text field for the buddy name because this will make it easier to add more buddy data to a "buddy online" message, such as online time or alias. The server sends this data, but right now ChatManager just discards it. ChatManager also understands tuple-based commands sent to its "talk" inbox. The following lists the commands it understands, and the corresponding actions it takes.
Example UsageSimple client with a truly horrible interface: class AIMHarness(component): def main(self): self.loginer = LoginHandler('sitar63112', 'sitar63112').activate() self.link((self.loginer, "signal"), (self, "internal inbox")) self.addChildren(self.loginer) while not self.dataReady("internal inbox"): yield 1 self.oscar = self.recv("internal inbox") queued = self.recv("internal inbox") self.unlink(self.oscar) self.chatter = ChatManager().activate() self.link((self.chatter, "heard"), (self, "outbox"), passthrough=2) self.link((self, "inbox"), (self.chatter, "talk"), passthrough=1) self.link((self.chatter, "outbox"), (self.oscar, "inbox")) self.link((self.oscar, "outbox"), (self.chatter, "inbox")) self.link((self, "internal outbox"), (self.chatter, "inbox")) while len(queued): self.send(queued[0], "internal outbox") del(queued[0]) while True: yield 1 def tuplefy(data): data = data.split() if len(data) > 1: data = ("message", data[0], " ".join(data[1:])) return data Pipeline(ConsoleReader(), PureTransformer(tuplefy), AIMHarness(), ConsoleEchoer() ).run() Kamaelia.Protocol.AIM.ChatManager.ChatManagerclass ChatManager(SNACExchanger)ChatManager() -> new ChatManager component. Inboxes
Outboxes
Methods defined hereWarning! You should be using the inbox/outbox interface, not these methods (except construction). This documentation is designed as a roadmap as to their functionalilty for maintainers and new component developers. __init__(self)x.__init__(...) initializes x; see x.__class__.__doc__ for signature cleanMessage(self, message)strips HTML tags off messages main(self)Main loop. receiveMessage(self, body)Extracts the sender and message text from SNAC body, and sends the tuple ("message", sender, message) to "heard". sendMessage(self, buddyname, text)constructs SNAC (04, 06), the "send message" SNAC and sends it to "outbox" FeedbackGot a problem with the documentation? Something unclear that could be clearer? Want to help improve it? Constructive criticism is very welcome - especially if you can suggest a better rewording! Please leave you feedback here in reply to the documentation thread in the Kamaelia blog. -- Automatic documentation generator, 05 Jun 2009 at 03:01:38 UTC/GMT |
Kamaelia
is an open source project originated from and guided by BBC
Research. For more information browse the site or get in
contact.
This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)
(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved.