Advertisement
Guest User

ketterer

a guest
Apr 25th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. var websocket = io.connect("http://localhost:8000");
  2. $(document).on("ready", iniciar);
  3. function iniciar() {
  4. //websocket.on("nombreDesdeServidor", recibirMensaje);
  5. $("#formulario").on("submit",enviarDatos);
  6. }
  7. function enviarDatos(e) {
  8. e.preventDefault();
  9. var jsonUser={
  10. "nombre": $("#nombre").val(),
  11. "desc": $("#desc").val(),
  12. "link":$("link").val()
  13. };
  14. console.log(jsonUser);
  15. websocket.emit("nuevoGrupo", jsonUser);
  16. //$("#nombre").fadeOut();
  17. }
  18. ----------------------------------------------------------------------------------------
  19. var port = process.env.PORT||8000,
  20. express = require('express'),
  21. app = express(),
  22. io = require('socket.io').listen(
  23. app.listen(port, function(){
  24. console.log('listening on¨* :8000');
  25. })
  26. ),
  27.  
  28.  
  29. mysql = require('mysql'),
  30. connection = mysql.createConnection({
  31. host : 'localhost',
  32. user : 'root',
  33. password : '',
  34. database : 'nodejs'
  35. });
  36.  
  37. connection.connect(function(err){
  38.  
  39. if(err){
  40. throw err;
  41. }else{
  42. console.log('conexion correcta.');
  43. }
  44. });
  45.  
  46. require('./config')(app, io);
  47. require('./routes')(connection,app,io);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement