Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Little fix for example/chat #774

Closed
wants to merge 4 commits into from

2 participants

@M1cRO

Little fix for example/chat

  • Don't send empty message
@rauchg
Owner

WIll fail for 0. How about if (msg.length)

@M1cRO

hm, work for "0", but "if (msg.length)" looks better

@rauchg
Owner

If the message is 0 it will get incorrectly filtered out, won't it ?

@M1cRO

no, all looks fine
screenshot: http://imm.io/hDN7
please use "if (msg.length)" this right way

@M1cRO

Changed msg to msg.length

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 1, 2012
  1. Don't send emtpy message

    M1cRO authored
  2. Don't send empty message

    M1cRO authored
  3. Update examples/chat/index.jade

    M1cRO authored
  4. Update examples/chat/app.js

    M1cRO authored
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 2 deletions.
  1. +3 −1 examples/chat/app.js
  2. +3 −1 examples/chat/index.jade
View
4 examples/chat/app.js
@@ -56,7 +56,9 @@ var io = sio.listen(app)
io.sockets.on('connection', function (socket) {
socket.on('user message', function (msg) {
- socket.broadcast.emit('user message', socket.nickname, msg);
+ if (msg.length) {
+ socket.broadcast.emit('user message', socket.nickname, msg);
+ }
});
socket.on('nickname', function (nick, fn) {
View
4 examples/chat/index.jade
@@ -38,7 +38,9 @@ html
});
function message (from, msg) {
- $('#lines').append($('<p>').append($('<b>').text(from), msg));
+ if (msg.length) {
+ $('#lines').append($('<p>').append($('<b>').text(from), msg));
+ }
}
// dom manipulation
Something went wrong with that request. Please try again.