Changes between Version 19 and Version 20 of ProposedWikiStart


Ignore:
Timestamp:
03/26/2012 01:03:43 PM (4 years ago)
Author:
itamar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ProposedWikiStart

    v19 v20  
    122122    <li class="active"><a href="#echoserver">Echo Server</a></li>
    123123    <li><a href="#webserver">Web server</a></li>
    124     <li><a href="#chatserver">Chat server</a></li>
     124    <li><a href="#pubsubserver">Publish/subscribe</a></li>
    125125</ul>
    126126}}}
     
    180180
    181181{{{
    182 #!div class="tab-pane" id="chatserver"
    183 Here's what a simple chat server might look like:
     182#!div class="tab-pane" id="pubsubserver"
     183Here's a simple publish/subscribe server, where clients see all messages posted by other clients:
    184184
    185185{{{
     
    188188from twisted.protocols import basic
    189189
    190 class ChatProtocol(basic.LineReceiver):
     190class PubProtocol(basic.LineReceiver):
    191191    delimiter = "\n"
    192192
     
    207207
    208208
    209 class ChatFactory(protocol.Factory):
     209class PubFactory(protocol.Factory):
    210210    def __init__(self):
    211211        self.clients = set()
    212212
    213213    def buildProtocol(self, addr):
    214         return ChatProtocol(self)
     214        return PubProtocol(self)
    215215
    216216
    217217if __name__ == '__main__':
    218     reactor.listenTCP(1025, ChatFactory())
     218    reactor.listenTCP(1025, PubFactory())
    219219    reactor.run()
    220220}}}