コード例 #1
0
 def send_stream(self, action):
     """Send a text stream representing the action."""
     data = TextStream.make_stream(action)
     log.debug(u"TO PEER: %s" % data)
     size = 0
     while size < len(data):
         data = data[size:]
         size = self.socket.send(data)
     return size
コード例 #2
0
 def testAcceptAction(self):
     expected = u'P2P 1 2 john'
     action = AcceptStartAction(name="john")
     stream = TextStream.make_stream(action)
     self.assertEqual(expected.lower(), stream.lower())
コード例 #3
0
 def testStartAction(self):
     expected = u'P2P 1 1 '
     action = StartAction()
     stream = TextStream.make_stream(action)
     self.assertEqual(expected.lower(), stream.lower())