Question

As a C++/C# programmer I'm pretty new in Javascript (not my choice, lame course at my university) and I've to dev a small programme using vert.x creating childs wich will count words contains in a text file.

I want to use point-to-point method.

Here's what I've actually done for the parent:

var vertx = require ('vertx');
var console = require('vertx/console');
var container = require('vertx/container')
var eb = require('vertx/event_bus');

vertx.fileSystem.OPEN_READ = 1
vertx.fileSystem.OPEN_WRITE = 2
vertx.fileSystem.CREATE_NEW = 4

vertx.createHttpServer().requestHandler(function(req)
{
  vertx.fileSystem.readFile('dataset.txt', function(err, res)
    {
        if (!err) 
        {

            var str = res.toString();
            var myarray = str.split(' ');

            for (var i = 0; i < myarray.length; i++)
            {
                myarray[i] = myarray[i].replace(".", "");
                myarray[i] = myarray[i].replace(",", "");
            }

            var config = {adresse: 'boap'}
            var id = container.deployVerticle('child.js', config, 1);
            var reply;

            vertx.setperiodic(1000, function sendmessage()
            {
                eb.send('lama', 'ping!', function(reply)
                {
                    console.log("received reply: " + reply);
                });
            });         
        }
    });



}).listen(1234, 'localhost');

Here's the child :

var eb = require('vertx/event_bus');
var console = require('vertx/console');
var container = require('vertx/container')

var log = container.logger;

log.info("in child.js, config is " + container.config.adresse);

eb.registerHandler('lama', function(message, replier) {
  console.log('Received message ' + message);
  // Now reply to it
  replier('pong!');
});

The problem is when I launch it I get the following error :

Succeeded in deploying verticle
Exception in JavaScript verticle:
TypeError: Cannot find function setperiodic in object [object Object].
        at file:/C:/Users/3wic/Documents/vert.x-2.1M2/bin/lama.js:30 (anonymous)

        at file:/C:/Users/3wic/Documents/vert.x-2.1M2/sys-mods/io.vertx~lang-rhi
no~2.0.0-final/vertx/file_system.js:47 (anonymous)

in child.js, config is boap

Anyone know why this function isn't recognized ?

Was it helpful?

Solution

Answered by tim_yates, check the comments

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top