]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
renamed OrderedConnection to StreamConnection
authorburris <burris>
Mon, 23 Dec 2002 03:19:57 +0000 (03:19 +0000)
committerburris <burris>
Mon, 23 Dec 2002 03:19:57 +0000 (03:19 +0000)
airhook.py
test_airhook.py

index 8d9443c52651c07cd3f24a1bd52b5c22cdb2e972..b72f9ea23afd67ad3f4abd89743bbdccedcceeee 100644 (file)
@@ -310,11 +310,15 @@ class ustr(str):
        def __ge__(self, other):
                return (self.getseq() - other.getseq()) % 2**16 < 256
                
-class OrderedConnection(AirhookConnection):
+class StreamConnection(AirhookConnection):
        """
-               this implements a simple protocol for ordered messages over airhook
+               this implements a simple protocol for a stream over airhook
                the first two octets of each message are interpreted as a 16-bit sequence number
                253 bytes are used for payload
+               
+               delegate should implement method:
+                 def dataCameIn(self, host, port, data):
+                       [...]
        """
        def __init__(self, transport, addr, delegate):
                AirhookConnection.__init__(self, transport, addr, delegate)
index 2fb68a22c0c2ef4c4e0f8905575df34cc3be43b8..014e13bd05ae311c060ffcc3da3315dc7b364985 100644 (file)
@@ -501,7 +501,7 @@ class BasicTests(unittest.TestCase):
                self.assertEqual(a.next, 255)
                self.assertEqual(a.outMsgNums[(a.outSeq-1) % 256], 254)
 
-class OrderedTests(unittest.TestCase):
+class StreamTests(unittest.TestCase):
        def setUp(self):
                self.noisy = 0
                class queuer:
@@ -511,10 +511,10 @@ class OrderedTests(unittest.TestCase):
                                self.msg+= data
                self.A = queuer()
                self.B = queuer()
-               self.a = OrderedConnection(StringIO(), (None, 'localhost', 4040), self.A)
-               self.b = OrderedConnection(StringIO(), (None, 'localhost', 4040), self.B)
+               self.a = StreamConnection(StringIO(), (None, 'localhost', 4040), self.A)
+               self.b = StreamConnection(StringIO(), (None, 'localhost', 4040), self.B)
 
-       def testOrderedSimple(self, num = 2**18, prob=1.0):
+       def testStreamSimple(self, num = 2**18, prob=1.0):
                f = open('/dev/urandom', 'r')
                a = self.a
                b = self.b
@@ -542,5 +542,5 @@ class OrderedTests(unittest.TestCase):
                self.assertEqual(self.A.msg, MSGB)
                self.assertEqual(self.B.msg, MSGA)
 
-       def testOrderedLossy(self, num = 2**18, prob=0.5):
-               self.testOrderedSimple(num, prob)
+       def testStreamLossy(self, num = 2**18, prob=0.5):
+               self.testStreamSimple(num, prob)