forked from platzi/mapa-turistico
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·34 lines (28 loc) · 820 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Cargamos módulos Node
var express = require('express');
var http = require('http');
// Creamos aplicación
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);
// Configuramos la aplicación
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.static(__dirname + '/public'));
});
// Routing
app.get('/', function(req, res) {
res.render('layout', {
title: 'Mapa en tiempo real',
description: 'Mi primer mapa'
});
});
io.sockets.on('connection', function (socket) {
socket.on('coords:me', function (data) {
socket.broadcast.emit('coords:user', data);
});
});
// Iniciamos server en el puerto 3000
server.listen(3000);
console.log('Servidor Node Js en http://localhost:3000');