This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Solicitamos al servidor los ultimos mensajes | |
* del historial registrado. | |
*/ | |
socket.emit('latest messages'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
socket.on('latest messages', function () { | |
messagesDAO.getLatest(50, function (err, messages) { | |
if (err) console.log('Error getting messages from history'); | |
socket.emit('latest messages', messages); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
socket.on('chat message', function(msg) { | |
messagesDAO.addMessage(msg.username, Date.now(), msg.message, function (err, nmsg) { | |
io.emit('chat message', msg); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var messageDAO = require('./dao/MessageDAO').MessageDAO; | |
... | |
... | |
MongoClient.connect('mongodb://'+mdbconf.host+':'+mdbconf.port+'/'+mdbconf.db, function (err, db) { | |
var usersDAO = new userDAO(db); // Initialize userDAO | |
var messagesDAO = new messageDAO(db); | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Server.js | |
* @author : DiganmeGiovanni | https://twitter.com/DiganmeGiovanni | |
* @Created on: 25 Oct, 2014 | |
* Updated on: 29 March, 2015 | |
*/ | |
/* Librerias necesarias para la aplicación */ | |
var express = require('express'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Data Access Object (DAO) para 'messages' | |
* Debe ser construido con un objeto conectado a la | |
* base de datos | |
* | |
* @Created on: 29 March, 2015 | |
*/ | |
function MessageDAO(db) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; | |
; Archivo helloEEPROM.asm | |
; FUNCIONA CON UN PIC16F84A | |
; | |
; @author: DiganmeGiovanni | |
; | |
; Lee un número binario de 4 bits del PORTA, escribe ese número a la | |
; memoria EEPROM interna del microcontrolador, hace una pequeña pausa, | |
; lee el número de la memoria EEPROM y escribe el número leido al | |
; PORTB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sincronizador; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileOutputStream; | |
import java.io.InputStream; | |
import java.io.OutputStream; | |
import java.util.ArrayList; | |
import javax.swing.JOptionPane; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* We should config the replica after start the 3 servers | |
* run this with a command like: | |
* mongo --port 27017 < mongodb_init_replica.js | |
*/ | |
config = { _id: "m101", members:[ | |
{ _id : 0, host : "localhost:27017"}, | |
{ _id : 1, host : "localhost:27018"}, | |
{ _id : 2, host : "localhost:27019"} ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Create directories for data | |
mkdir -p /data/rs1 /data/rs2 /data/rs3 | |
# Start 3 server processes on three diferent ports | |
mongod --replSet m101 --logpath "1.log" --dbpath /data/rs1 --port 27017 --oplogSize 64 --fork --smallfiles | |
mongod --replSet m101 --logpath "2.log" --dbpath /data/rs2 --port 27018 --oplogSize 64 --smallfiles --fork | |
mongod --replSet m101 --logpath "3.log" --dbpath /data/rs3 --port 27019 --oplogSize 64 --smallfiles --fork |