From a7879e3d52cd2d2338a4ff100025772086a3bc6e Mon Sep 17 00:00:00 2001 From: burris Date: Mon, 23 Dec 2002 03:19:57 +0000 Subject: [PATCH] renamed OrderedConnection to StreamConnection --- airhook.py | 8 ++++++-- test_airhook.py | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) 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) -- 2.39.5