Note that there are some explanatory texts on larger screens.

plurals
  1. PORedis pub/sub for chat server in node.js
    primarykey
    data
    text
    <p>I'm trying to work the Redis Cookbook example:</p> <pre><code>var http = require('http'), io = require('socket.io') fs = require('fs'), redis = require('redis'), rc = redis.createClient(9189, "pike.redistogo.com"); rc.auth("passwd", function() { console.log("Connected! to redistogo!");}); rc.on("connect", function() { rc.subscribe("chat"); console.log("rc connect event"); }); </code></pre> <p>I am successful through here but never get "message."</p> <pre><code>rc.on("message", function (channel, message) { console.log("Sending: " + message); socketio.sockets.emit('message', message); }); webpage = http.createServer(function(req, res){ console.log('webpage request starting...'); fs.readFile('./index.htm', function(error, content) { if (error) { res.writeHead(500); res.end(); } else { res.writeHead(200, { 'Content-Type': 'text/html' }); res.end(content, 'utf-8'); } }); }); webpage.listen(7777); </code></pre> <p>my client side index.htm is this</p> <pre><code>&lt;!docttype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;script src ="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"&gt; &lt;/script&gt; &lt;script src="http://www.heaphash.com:7777/socket.io/socket.io.js"&gt;&lt;/script&gt; &lt;script&gt; var socket = io.connect('www.heaphash.com', { port: 7777}); socket.on('message', function(data){ var li = new Element('li').insert(data); $('messages').insert({top: li}); } &lt;/script&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Chat with Redis&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;ul id="messages"&gt; &lt;!-- chat messages go here --&gt; &lt;/ul&gt; &lt;form id="chatform" action=""&gt; &lt;input id="chattext" type="text" value="" /&gt; &lt;input type="submit" value="Send" /&gt; &lt;/form&gt; &lt;script&gt; $('#chatform').submit(function(){ socket.emit('message', $('chattext').val()); $('chattext').val(""); //cleanup the field return false; }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>how does a client publish to a specific Redis "chat" channel.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload