#!/usr/bin/env python

# Both have a very small chance of occuring

from twisted.internet import reactor
from mesh import Mesh, MeshNode, packet_type, BYE, DATA
import sys

NUMNODES = 2
DELAY = 0.1

m = Mesh()

class TestMeshNode(MeshNode):

  def newNode (self, data):
    MeshNode.newNode (self, data)
    print data + " joined"
    self.fail(data)

  def leftNode (self, data):
    MeshNode.leftNode (self, data)
    print data + " left"

n = TestMeshNode("node", m)
m.addMeshNode(n)

failnode = MeshNode("failnode", m)
m.addMeshNode(failnode)

# Connect all nodes to all others. 1024 bytes/s bandwidth, 50ms delay and 0%
# packet loss.. (bandwidth and delay aren't implemented just yet)
m.connect_full(1024, 50, 0.30)

reactor.run()

@@ -233,16 +233,212 @@
 shNode):
+%0A  def __init__(self, name, mesh):%0A    MeshNode.__init__(self, name, mesh)%0A    self.count = 0%0A%0A  def node_connected (self):%0A    MeshNode.node_connected(self)%0A    reactor.callLater (0.5, self.push)
 %0A%0A  def 
@@ -523,28 +523,8 @@
 ned%22
-%0A    self.fail(data)
 %0A%0A  
@@ -611,16 +611,294 @@
  left%22%0A%0A
+  def push (self):%0A    reactor.callLater (2, self.push)%0A    self.pushInput (self.name + %22 %22 + str(self.count))%0A    self.count += 1%0A%0Aclass FailMeshNode(TestMeshNode):%0A  def newNode (self, data):%0A    TestMeshNode.newNode (self, data)%0A    reactor.callLater (5, self.fail, %22node%22)%0A%0A
 n = Test
@@ -946,16 +946,20 @@
 lnode = 
+Fail
 MeshNode
@@ -1173,9 +1173,9 @@
 , 0.
-3
+0
 0)%0A%0A

Update test to send messages on a regular basis to see check if data is still send after a reset