Skip to content

Instantly share code, notes, and snippets.

@alvarotrigo
Created February 26, 2018 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvarotrigo/9192b47023596f4d0034603e7e1faf3b to your computer and use it in GitHub Desktop.
Save alvarotrigo/9192b47023596f4d0034603e7e1faf3b to your computer and use it in GitHub Desktop.
socketio
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var swig = require('swig');
var mysql = require('mysql');
var routes = require('./routes/index');
var tickets = require('./routes/tickets');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
server.listen(8080, function() {
console.log('Server running in http://localhost:8080');
});
io.on('connection', function(socket) {
console.log('Un cliente se ha conectado');
socket.on('updated-task', function(text) {
socket.broadcast.emit('user-modified-task', true);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment