Permalink
Browse files

Version 0.2.0, see CHANGELOG

  • Loading branch information...
1 parent 2bc0751 commit 5817d53c4bf44b2b0891fa7265c1f0e2bb1a03a2 Justin committed Apr 20, 2012
Showing with 29 additions and 23 deletions.
  1. +5 −0 CHANGELOG.md
  2. +1 −1 VERSION
  3. +2 −2 index.html
  4. +21 −20 server.js
View
@@ -1,5 +1,10 @@
## CHANGELOG
+### Version 0.2.0
+- Fixed a bug where other ticker requests would stream in. For example, if a client requested GOOG, and then another client connected requesting MSFT, the first connected client would see MSFT stream in.
+
+- Changed `index.html` to request the socket.io javascript file, and connect on `localhost`, instead of hard-coding the NodeSocket demo machine.
+
### Version 0.1.1
- Added `clearInterval()` on `socket.disconnect()`
View
@@ -1 +1 @@
-0.1.1
+0.2.0
View
@@ -7,11 +7,11 @@
</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.js"></script>
- <script type="text/javascript" src="http://xhv51cz0.nodesocket.com:4000/socket.io/socket.io.js"></script>
+ <script type="text/javascript" src="http://localhost:4000/socket.io/socket.io.js"></script>
</head>
<script type="text/javascript">
$(document).ready(function() {
- var socket = io.connect("http://xhv51cz0.nodesocket.com:4000");
+ var socket = io.connect("http://localhost:4000");
socket.on('quote', function(data) {
var data = $("<pre>" + data + "</pre><hr />");
$("#quotes").append(data);
View
@@ -1,7 +1,7 @@
/**
* Quote Stream
*
- * @version 0.1.1
+ * @version 0.2.0
* @author NodeSocket <http://www.nodesocket.com> <hello@nodesocket.com>
*/
@@ -51,11 +51,28 @@ app.get('/:ticker/', function(req, res) {
res.sendfile(__dirname + '/index.html');
});
-function get_quote(p_socket) {
+io.sockets.on('connection', function(socket) {
+ var local_ticker = ticker;
+ ticker = "";
+
+ //Run the first time immediately
+ get_quote(socket, local_ticker);
+
+ //Every N seconds
+ var timer = setInterval(function() {
+ get_quote(socket, local_ticker)
+ }, FETCH_INTERVAL);
+
+ socket.on('disconnect', function () {
+ clearInterval(timer);
+ });
+});
+
+function get_quote(p_socket, p_ticker) {
http.get({
host: 'www.google.com',
port: 80,
- path: '/finance/info?client=ig&q=' + ticker
+ path: '/finance/info?client=ig&q=' + p_ticker
}, function(response) {
response.setEncoding('utf8');
var data = "";
@@ -86,20 +103,4 @@ function get_quote(p_socket) {
}
});
});
-}
-
-io.sockets.on('connection', function(socket) {
- var timer;
-
- //Run the first time immediately
- get_quote(socket);
-
- //Every N seconds
- timer = setInterval(function() {
- get_quote(socket)
- }, FETCH_INTERVAL);
-
- socket.on('disconnect', function () {
- clearInterval(timer);
- });
-});
+}

0 comments on commit 5817d53

Please sign in to comment.