Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var websocket = io.connect("http://localhost:8000");
- $(document).on("ready", iniciar);
- function iniciar() {
- //websocket.on("nombreDesdeServidor", recibirMensaje);
- $("#formulario").on("submit",enviarDatos);
- }
- function enviarDatos(e) {
- e.preventDefault();
- var jsonUser={
- "nombre": $("#nombre").val(),
- "desc": $("#desc").val(),
- "link":$("link").val()
- };
- console.log(jsonUser);
- websocket.emit("nuevoGrupo", jsonUser);
- //$("#nombre").fadeOut();
- }
- ----------------------------------------------------------------------------------------
- var port = process.env.PORT||8000,
- express = require('express'),
- app = express(),
- io = require('socket.io').listen(
- app.listen(port, function(){
- console.log('listening on¨* :8000');
- })
- ),
- mysql = require('mysql'),
- connection = mysql.createConnection({
- host : 'localhost',
- user : 'root',
- password : '',
- database : 'nodejs'
- });
- connection.connect(function(err){
- if(err){
- throw err;
- }else{
- console.log('conexion correcta.');
- }
- });
- require('./config')(app, io);
- require('./routes')(connection,app,io);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement