1. Jesper Nøhr
  2. puck

Commits

Jesper Nøhr  committed 1314524

twistd app, simple linereceiving hub

  • Participants
  • Branches default

Comments (0)

Files changed (6)

File puck/__init__.py

Empty file added.

File puck/core.py

View file
+VERSION = "0.1"

File puck/hub.py

View file
+from twisted.internet.protocol import Factory, Protocol
+from twisted.protocols.basic import LineOnlyReceiver
+
+class Hub(LineOnlyReceiver):
+    def connectionMade(self):
+        self.stack = { }
+        
+    def lineReceived(self, line):
+        self.transport.write('you said: %s\r\n' % line)
+        self.transport.write('my stack is %s' % repr(self.stack))
+        self.transport.loseConnection()
+
+class HubFactory(Factory):
+    protocol = Hub
+    

File setup.cfg

View file
+[install]
+optimize = 1

File setup.py

View file
+#!/usr/bin/python
+import sys
+from setuptools import setup, find_packages
+from puck.core import VERSION
+
+setup(
+    name="puck",
+    version=VERSION,
+    description="Puck",
+    author="Jesper Noehr",
+    author_email="jesper@noehr.org",
+    maintainer="Jesper Noehr",
+    maintainer_email="jesper@noehr.org",
+    packages=find_packages(),
+    url="http://bitbucket.org/jespern/puck/",
+    install_requires=[]
+)

File tests/puckd.tac

View file
+#!/usr/bin/python
+import os, sys
+sys.path.append('../')
+
+from twisted.application import service, internet
+from puck.hub import HubFactory
+
+def getHub():
+    return internet.TCPServer(8080, HubFactory())
+    
+application = service.Application("Demo Puck Server")
+service = getHub()
+service.setServiceParent(application)