Permalink
Browse files

fixed color script on client and added static socket.html serving fro…

…m socket.js
  • Loading branch information...
1 parent c827f5c commit 7e577f499688096a6df1fd130e50e3467cc690ae @chrismatthieu chrismatthieu committed with mheadd Apr 19, 2011
Showing with 21 additions and 8 deletions.
  1. +3 −1 socket.html
  2. +15 −4 socket.js
  3. +3 −3 tropo-redis.php
View
@@ -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', {
@@ -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;
});
});
View
@@ -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.
View
@@ -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();

0 comments on commit 7e577f4

Please sign in to comment.