From 6c188f1f0f5b0d429473e7e21c67e2aabd7cdbcd Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 24 Apr 2006 13:19:10 -0400 Subject: [PATCH] Fix up p2p chat --- chat/chat.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/chat/chat.py b/chat/chat.py index 840ba9cc..53057239 100755 --- a/chat/chat.py +++ b/chat/chat.py @@ -96,14 +96,21 @@ class GroupChat(Chat): class ChatRequestHandler(object): - def __init__(self, parent): + def __init__(self, parent, chat_view, chat_label): self._parent = parent + self._chat_view = chat_view + self._chat_label = chat_label def message(self, message): client_address = network.get_authinfo() buddy = self._parent.find_buddy_by_address(client_address[0]) if buddy: - self.recv_message(buddy, message) + chat = buddy.chat() + if not chat: + chat = BuddyChat(self, buddy, self._chat_view, self._chat_label) + buddy.set_chat(chat) + chat.recv_message(message) + return True class ChatActivity(activity.Activity): def __init__(self): @@ -201,7 +208,7 @@ class ChatActivity(activity.Activity): print "Done announce." # Create the P2P chat XMLRPC server - self._p2p_req_handler = ChatRequestHandler(self) + self._p2p_req_handler = ChatRequestHandler(self, self._chat_view, self._chat_label) self._p2p_server = network.GlibXMLRPCServer(("", 6666)) self._p2p_server.register_instance(self._p2p_req_handler)