From: burris Date: Mon, 23 Dec 2002 03:19:57 +0000 (+0000) Subject: renamed OrderedConnection to StreamConnection X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a7879e3d52cd2d2338a4ff100025772086a3bc6e;p=quix0rs-apt-p2p.git renamed OrderedConnection to StreamConnection --- diff --git a/airhook.py b/airhook.py index 8d9443c..b72f9ea 100644 --- a/airhook.py +++ b/airhook.py @@ -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) diff --git a/test_airhook.py b/test_airhook.py index 2fb68a2..014e13b 100644 --- a/test_airhook.py +++ b/test_airhook.py @@ -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)