func sendMessages(t *natty.Traversal, serverId waddell.PeerId, traversalId uint32) { for { msgOut, done := t.NextMsgOut() if done { return } log.Printf("Sending %s", msgOut) out <- waddell.Message(serverId, idToBytes(traversalId), []byte(msgOut)) } }
func receiveMessages(t *natty.Traversal, traversalId uint32) { for wm := range in { msg := message(wm.Body) if msg.getTraversalId() != traversalId { log.Printf("Got message for unknown traversal %d, skipping", msg.getTraversalId()) continue } log.Printf("Received: %s", msg.getData()) msgString := string(msg.getData()) if READY == msgString { // Server's ready! serverReady <- true } else { t.MsgIn(msgString) } } }