thanks for the reply. sorry i was not clear with my subject title and
the actual post!
there are two questions:
1/. when sending a message, i don't want to display this back to the
user who sent it.
2/. how to deal with PM to one or a set of users?
On Jan 23, 6:25 pm, Ian Serlin <i...@ianserlin.com> wrote:
> Typically when I have done this in the past I've just ignored it on the
> client-side. Unless you're sending huge amounts of text in the message
> you're not saving any significant bandwidth by not broadcasting the message
> to the user who sent the message. It looks like you're already keeping a
> unique name property on each client that's accessible to the client so this
> should be easy.
so this is a use case as per the discussion on github (i think i read
it there) where a user sends a file and we don't want to send the same
file back to the user who sends it!
what i was looking for is to modify:
group.now.receiveMessage(this.now.name+'@'+this.now.serverRoom,
message);
so that it includes the https://github.com/Flotype/now/pull/80#issuecomment-1448994
everyone.exclude([this.user.clientId]).now.receive(this.now.name + ":
" + msg);
i am unsure how to do the:
var group = nowjs.getGroup(this.now.serverRoom);
and include the .exclude([this.user.clientId])
> Alternatively, in terms of application flow, if you're talking about just
> displaying user messages (as opposed to sending control messages) you could
> add the message the user typed to the chat log only after it's received
> back from the server, with no filtering, which means you know the message
> actually went through.
> Sorry if that's not the answer you were looking for. If you really want to
> filter on the server-side without a lot of extra lines of code you could
> probably do something withhttp://nowjs.org/doc/symbols/Group#excludebut I
> wouldn't recommend it. A real answer to this server-side would be to do
> something like now-middleware and being able to hook into the stack where
> the server is calling the client (not client calling the server as it is
> now) and run your exclusion code that way.
the way i understand it is that this is all done on the server, as the
user sends the 'message' which is then broadcasted to all the users
from the server, but excluding the original poster? perhaps i am
misunderstanding it?
> HTH,
> Ian Serlin
> i...@ianserlin.com
> http://u <http://ianserlin.com>seful.iohttp://www.linkedin.com/in/ianserlin
> @spiceninja
> On Mon, Jan 23, 2012 at 5:07 AM, Norman Khine <nor...@khine.net> wrote:
> > Hello,
> > I have recently discovered nowjs and is awesome, thank you!
> > How do i modify the code so that to exclude the user who is posting
> > it?
> > // code from
> >http://www.adityaravishankar.com/2011/10/nowjs-node-js-tutorial-creat...
> > // Send message to everyone on the users group
> > everyone.now.distributeMessage = function(message){
> > console.log(this.user.clientId);
> > //console.log('Received message from '+this.now.name +' in
> > serverroom '+this.now.serverRoom);
> > var group = nowjs.getGroup(this.now.serverRoom);
> > group.now.receiveMessage(this.now.name+'@'+this.now.serverRoom,
> > message);
> > };
> > many thanks