Skip to content
Browse files

added universe view

  • Loading branch information...
1 parent 3231b31 commit 55aa22b8670615475eb726db9e37b8d8a180eea1 @JustinBeckwith committed Sep 25, 2012
Showing with 13 additions and 2 deletions.
  1. +10 −2 frontend/server.js
  2. +3 −0 frontend/views/index.html
View
12 frontend/server.js
@@ -19,6 +19,8 @@ var serviceBusService = azure.createServiceBusService(sbNamespace, sbKey);
var subscriptionId = uuid.v4();
var topicName = "wazages";
var picCache = new Object();
+var universe = "universe";
+picCache[universe] = [];
serviceBusService.createTopicIfNotExists(topicName, function (error) {
if (!error) {
@@ -101,7 +103,8 @@ function getFromTheBus() {
var body = JSON.parse(message.body);
console.log('new pic published from: ' + body.city);
cachePic(body.pic, body.city);
- io.sockets. in (body.city).emit('newPic', body.pic);
+ io.sockets.in(body.city).emit('newPic', body.pic);
+ io.sockets.in(universe).emit('newPic', body.pic);
}
getFromTheBus();
});
@@ -115,10 +118,15 @@ function cachePic(data, city) {
if (!picCache[city])
picCache[city] = [];
- // add the picture to the end of the queue
+ // add the picture to the end of the queue for the city and universe
picCache[city].push(data);
+ picCache[universe].push(data);
// only allow 10 items in the queue per city
if (picCache[city].length > 10)
picCache[city].shift();
+
+ // keep the universe queue down to 10 as well
+ if (picCache[universe].length > 10)
+ picCache[universe].shift();
}
View
3 frontend/views/index.html
@@ -13,5 +13,8 @@
<a href="/san-francisco">San Francisco</a>
<a href="/washington-dc">Washington DC</a>
<a href="/rome">Rome</a>
+ <br>
+ <br>
+ <a href="/universe">Universe</a>
</body>
</html>

0 comments on commit 55aa22b

Please sign in to comment.
Something went wrong with that request. Please try again.