Skip to content

Commit

Permalink
Show own message right away
Browse files Browse the repository at this point in the history
  • Loading branch information
felixge committed Nov 7, 2009
1 parent aacd6b2 commit d13f576
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion client/example/paste_chat/js/lib/chat.js
Expand Up @@ -131,9 +131,18 @@ Chat.prototype._handleLeave = function(leaver) {
};

Chat.prototype._handleMessage = function(message) {
// Ignore messages we send ourselves unless this is request #1 (history fetch)
var ignore = (message._client_id == this.user.client_id)
&& (this.channel.requestNum > 0);

if (ignore) {
return false;
}
this.ui.userMessage(message);
};

Chat.prototype.send = function(message) {
this.channel.emit('message', {user: this.user.name, text: message});
message = {user: this.user.name, text: message};
this.channel.emit('message', message);
this.ui.userMessage(message);
};
2 changes: 2 additions & 0 deletions client/lib/jquery.node-channel.js
Expand Up @@ -264,6 +264,7 @@ try {

this.timeout = 45 * 1000;
this.pause = 1 * 1000;
this.requestNum = 0;
};
node.inherits(nodeChannel.Channel, node.EventEmitter);

Expand Down Expand Up @@ -310,6 +311,7 @@ try {
var self = this;
request.addCallback(function(r) {
self._emitHistory(r.history);
self.requestNum++;

setTimeout(function() {
self.listen();
Expand Down

0 comments on commit d13f576

Please sign in to comment.