Created
April 1, 2015 03:36
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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