Permalink
Browse files

Fikset noe websocketgreier

  • Loading branch information...
1 parent 99909c3 commit 76baac1c03196ea55c31f0591f2a2fe6e373d099 @heim committed Nov 5, 2013
Showing with 84 additions and 84 deletions.
  1. +10 −11 index.js
  2. +55 −52 public/index.html
  3. +19 −21 public/lib/pres.js
View
@@ -104,25 +104,24 @@ io = io.listen(server, {
log: false
});
+redisClient.subscribe('realtime');
+
+redisClient.on('message', function(channel, message) {
+ console.log("message: " + message);
+ if(channel == 'realtime') {
+ socket.emit('redis', message);
+ }
+});
+
io.sockets.on('connection', function(sock) {
socket = sock;
socket.on('redis-term', function(data) {
redis_term.write(data);
});
- redisClient.subscribe('realtime');
-
- redisClient.on('message', function(channel, message) {
- console.log("got message " + message);
- console.log("got channel " + channel);
- if(channel == 'realtime') {
- socket.emit('redis', message);
- }
-
- });
socket.on('disconnect', function() {
- redisClient.unsubscribe();
+ // redisClient.unsubscribe();
socket = null;
});
View
@@ -463,92 +463,95 @@
class: cols three
<h1><span>Praksis</span></h1>
-<div class="col">
-.circle.yellow.centered[Redis]
-<h1><span>Key-value</span></h1>
-
-* low-level api
+<div class="cols three">
+ <div class="col">
+ .circle.green.centered[MongoDB]
+ </div>
--
-
-* data structure server
+ <div class="col">
+ .circle.yellow.centered[Redis]
+ </div>
--
-
-* in-memory
+ <div class="col">
+ .circle.lightbrown.centered[neo4j]
+ </div>
+</div>
--
-
-* eventually consistent
+<div class="cols three">
+ <div class="col">
+ # <span>Dokumentdatabase</span>
+ </div>
--
-
-* Relaxed consistency
+ <div class="col">
+ # <span> Key-value +++</span>
+ </div>
--
-
+ <div class="col">
+ # <span>Grafdatabase</span>
+ </div>
</div>
-<div class="col">
-.circle.green.centered[MongoDB]
-<h1><span>Dokumentdatabase</span></h1>
---
+???
-* ingen relasjoner
---
-* embedded documents
---
+# Mongo
+* ingen relasjoner
+* embedded documents
* skalerer meget godt horisontalt
---
-
* ikke ACID p.g.a. ingen transaksjoner på tvers av dokumenter
---
-
* eventually consistent
---
-
* write concerns
---
-
* Strong consistency ved single-master-system
---
-
* Reading from secondaries -> relaxed consistency
---
-</div>
-<div class="col">
-.circle.lightbrown.centered[neo4j]
-<h1><span>Grafdatabase</span></h1>
---
-* ACID
---
+# Neo
+* ACID
* optimalisert for sammenkoblede data
---
-
* eks. hvem følger hvem på twitter
---
-
* Consistent, Available, men *ikke* distribuert
-</div>
+
+---
+name: Redis
+class: round
+
+![](img/redis.png)
+
???
-Redis: Relaxed consistency, mulig å konfigurere at den ikke tar imot writes med mindre N-slaver er koblet til.
+# Redis
-MongoDB: Replication.
+* limet i webapplikasjonen
+* data structure server
+ * løser veldig mange normale problemer
+ * køer
+ * expiry
+ * caching
+ * ranking
+ * telling
+* in-memory så ikke durable
+* relaxed consistency ved distribuerte installasjoner
+* har et veldig lav-nivå api
+* mange forskjellige kommandoer som gjør èn ting og den tingen gjør de bra
---
-name: terminal
-# <span>Terminal</span>
+name: redis-term
+class: cols white
+# <span>Redis</span>
<div id="redis-term"></div>
<div style="clear: both"></div>
-<ul id="list"></ul>
+
+
+<ul id="redis-list"></ul>
<p>
- <a href="#" id="resume">Resume</a> navigation
- <a href="#" id="ls">ls</a>
+ <a href="#" id="resume">Resume</a>
+ <a href="#" class="redis-cmd" data-command="foo">ls</a>
</p>
View
@@ -1,12 +1,11 @@
-
var slideshow = remark.create({highlightStyle: "solarized"});
slideshow.on('showSlide', function(slide) {
- if(slide.properties.name == "terminal") {
- console.log("pausing");
+ if(slide.properties.name == "redis-term") {
slideshow.pause();
}
});
+
document.getElementById('resume').onclick = function (e) {
slideshow.resume();
e.preventDefault();
@@ -19,40 +18,39 @@ var processed = [];
window.onload = function() {
var socket = io.connect();
socket.on('connect', function() {
- var term = new Terminal({
+ var redis_term = new Terminal({
cols: 80,
rows: 20,
useStyle: true,
screenKeys: true
});
- term.on('data', function(data) {
+ redis_term.on('data', function(data) {
socket.emit('redis-term', data);
});
- document.getElementById('ls').onclick = function (e) {
- term.write('ls\n');
- socket.emit('redis-term', 'ls\n');
+ $('.redis-cmd').click(function (e) {
+ var command = $(e.target).data('command');
+ console.log(command);
+ redis_term.write(command);
+ socket.emit('redis-term', command);
e.preventDefault();
- };
-
- term.open(document.getElementById('redis-term'));
-
- term.write('\x1b[31mWelcome to term.js!\x1b[m\r\n');
+ });
- socket.on('redis-term', function(data) {
- term.write(data);
- });
+ redis_term.open(document.getElementById('redis-term'));
+ socket.on('redis-term', function(data) {
+ redis_term.write(data);
+ });
+ socket.on('disconnect', function() {
+ redis_term.destroy();
+ });
- socket.on('disconnect', function() {
- term.destroy();
- });
});
-
socket.on('redis', function(data) {
- $("#list").append('<li>' + data + '</li>');
+ $("#redis-list").append('<li>' + data + '</li>');
});
+
};

0 comments on commit 76baac1

Please sign in to comment.