Amnor February 2016

My javascript server code can read a "2011", why not a "20,11" if they are both String?

I'm connecting Storm to javascript via redis. The redis part works fine, but when I try to publish tuples(really Strings), my code (an example from internet just a little modified) doesn't recieve a thing, and redis recieves well the tuples. Here's my code:

/*
    Node.js server script
    Required node packages: express, redis, socket.io
*/
const PORT = 3000;
const HOST = 'localhost';

var express = require('express'),
    http = require('http'), 
    server = http.createServer(app);
    log('info', 'connected to express');
var app = express();

const redis = require('redis');
const client = redis.createClient();
log('info', 'connected to redis server');

const io = require('socket.io');

if (!module.parent) {
    server.listen(PORT, HOST);
    const socket  = io.listen(server);

    socket.on('connection', function(client) {
        const subscribe = redis.createClient()
        subscribe.subscribe('realtime');

        subscribe.on("message", function(channel, message) {
            client.send(message);
            log('msg', "received from channel #" + channel + " : " + message);
        });

        client.on('message', function(msg) {
            log('debug', msg);
        });

        client.on('disconnect', function() {
            log('warn', 'disconnecting from redis');
            subscribe.quit();
        });
    });
}

function log(type, msg) {

    var color   = '\u001b[0m',
        reset = '\u001b[0m';

    switch(type) {
        case "info":
            color = '\u001b[36m';
            break;
        case "warn":
            color = '\u001b[33m';
            break;
        case "error":
            color = '\u001b[31m';
            break;
        case "msg":
            color = '\u001b[34m';
            break;
        default:
            color = '\u001b[0m'
    }

    console.log(color + '   ' + type + '  - ' + reset + msg);
}

It send to terminal the message when i send ints, but not with tuples.I am just quite

Answers


Amnor February 2016

When I sent the messages, in the treatmen at redis, they where splitted, now they aren't, and the messages arrives to the client.

Thanks for your answers!

Post Status

Asked in February 2016
Viewed 1,325 times
Voted 8
Answered 1 times

Search




Leave an answer