Skip to content

Instantly share code, notes, and snippets.

@giobyte8
Created April 1, 2015 03:36
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 giobyte8/369ca711ac681dcd9595 to your computer and use it in GitHub Desktop.
Save giobyte8/369ca711ac681dcd9595 to your computer and use it in GitHub Desktop.
Parte 3 | Creando un sistema de chat sobre NodeJS con Socket.IO, ExpressJS, MongoDB, Foundation y Openshift
/**
* Emitimos un evento de tipo 'chat message' cada vez
* que se presiona 'Enter' en el textarea y enviamos
* su contenido como mensaje al servidor.
*/
$('#new-msg').keyup(function (evt) {
if (evt.keyCode === 13) {
var nmsg = {
username : user._id,
message : $('#new-msg').val()
}
socket.emit('chat message', nmsg);
$('#new-msg').val('');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment