diff openwebchat.py @ 61:c1b46b60e838

The listen endpoint can now be passed a start msg id.
author Atul Varma <varmaa@toolness.com>
date Tue, 28 Apr 2009 23:07:12 -0700
parents aa0763886ec9
children b19641a0d5ad
line wrap: on
line diff
--- a/openwebchat.py	Tue Apr 28 22:10:24 2009 -0700
+++ b/openwebchat.py	Tue Apr 28 23:07:12 2009 -0700
@@ -49,6 +49,7 @@
         self.__file.flush()
 
 class OpenWebChatServer(object):
+    LISTEN_TEMPLATE = re.compile('listen/multipart\?start=([0-9]+)')
     REDIRECT_TEMPLATE = re.compile('\/([A-Za-z0-9_]+)')
     URL_TEMPLATE = re.compile('\/([A-Za-z0-9_]+)/(.*)')
 
@@ -142,9 +143,10 @@
 
     def _until_conv_request_processed(self, addr, headers, method,
                                       conv_name, page):
-        if page == 'listen/multipart':
+        listen_match = self.LISTEN_TEMPLATE.match(page)
+        if listen_match:
+            i = int(listen_match.group(1))
             yield self._until_multipart_header_sent(self.BOUNDARY)
-            i = 0
             conv = self._convs.get(conv_name)
             while 1:
                 while i < len(conv):