Skip to content

Commit

Permalink
fixed color script on client and added static socket.html serving fro…
Browse files Browse the repository at this point in the history
…m socket.js
  • Loading branch information
chrismatthieu authored and mheadd committed Apr 19, 2011
1 parent c827f5c commit 7e577f4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 3 additions & 1 deletion socket.html
Expand Up @@ -5,6 +5,7 @@
<script type="text/javascript" src="http://127.0.0.1:8000/socket.io/socket.io.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var olddata = "red";

// Create a new connection
var socket = new io.Socket('127.0.0.1', {
Expand All @@ -21,7 +22,8 @@
// When we get a message, add the appropirate CSS class.
socket.on('message', function(data) {
console.log('Received a message from the server: ' + data);
$("#color").addClass(data);
$("#color").removeClass(olddata).addClass(data);
olddata = data;
});

});
Expand Down
19 changes: 15 additions & 4 deletions socket.js
Expand Up @@ -9,16 +9,27 @@ var io = require('socket.io');
var redis = require('redis');
var http = require('http');
var sys = require('sys');
var fs = require('fs'),
index;

fs.readFile('./socket.html', function (err, data) {
if (err) {
throw err;
}
index = data;
});

// Redis config settings.
var redisHost = '';
var redisPort = 6379;
var redisPass = '';
var redisHost = 'bass.redistogo.com';
var redisPort = 9219;
var redisPass = '1604d5037f6fd79b71f158019a1eff04';

// Create a web server for Socket IO to use.
var server = http.createServer(function(req, res){
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<h1>This is a node web server.</h1>');
// res.end('<h1>This is a node web server.</h1>');
res.write(index);
res.end();
});

// Specify the port the server should listen on.
Expand Down
6 changes: 3 additions & 3 deletions tropo-redis.php
Expand Up @@ -7,9 +7,9 @@
*/

// Redis settings
define("REDIS_HOST", "");
define("REDIS_PORT", 6379);
define("REDIS_PASS", "");
define("REDIS_HOST", "bass.redistogo.com");
define("REDIS_PORT", 9219);
define("REDIS_PASS", "1604d5037f6fd79b71f158019a1eff04");

$redis = new Redis(REDIS_HOST, REDIS_PORT);
$redis->connect();
Expand Down

0 comments on commit 7e577f4

Please sign in to comment.