Closed alsonkemp closed 13 years ago
Hi alsonkemp,
We're working on a feature with this functionality that will be released soon. Thanks!
Hi @alsonkemp,
I've just built this feature.
https://github.com/Flotype/now/commit/00377ea881c53680281394b6f7736b0ceca206a2
use it as follows:
nowjs.getClient("some-client-id", function(){
this.now.whatever():
// this.user.clientId == "some-client-id" // true
});
Can someone write a simple example to send a message to a client id?
nowjs.getClient(clientId, function(){
this.now.someFunction();
});
Eric
On Mon, Jun 13, 2011 at 9:07 PM, amitda < reply@reply.github.com>wrote:
Can someone write a simple example to send a message to a client id?
Reply to this email directly or view it on GitHub: https://github.com/Flotype/now/issues/33#issuecomment-1363693
510-691-3951 EECS Student at UC Berkeley http://ericzhang.com
Thanks Eric.
Is there a way of integrating this into multi-room chat example?
Yep it can definitely be integrated but the multi-room chat example does not have any of the user interface necessary to integrate it.
I am working on it now... if I am successful, I will upload it here
Great to hear! Let me know if you need further help.
Eric
On Mon, Jun 13, 2011 at 9:23 PM, amitda < reply@reply.github.com>wrote:
I am working on it now... if I am successful, I will upload it here
Reply to this email directly or view it on GitHub: https://github.com/Flotype/now/issues/33#issuecomment-1363755
510-691-3951 EECS Student at UC Berkeley http://ericzhang.com
Hello,
Is there an error callback function on now.getClient in case the socket is closed or does not exist ?
Thanks a lot, Luc
Is there a best practice on knowing which clientId to use with getClient? Should we use a userID that already exists? Pull the clientID from the socket.io (and if so, any examples how best to)?
I'm trying to implement a multi-room chat session, where users can join and leave rooms, but still missing exactly how to tell a group that a user should be added or removed from a room.
Hi Jay,
The best way is to use the this.user.clientId
which is available whenever
this.now
and this.user
are available.
One way to do what you describe i using the join event
mygroup.on('join', function(){
mygroup.now.notify(this.user.clientId + ' has joined');
// this.user.clientId can also be stored for use in nowjs.getClient later
});
On Wed, Sep 28, 2011 at 4:52 PM, Jay Crossler < reply@reply.github.com>wrote:
Is there a best practice on knowing which clientId to use with getClient? Should we use a userID that already exists? Pull the clientID from the socket.io (and if so, any examples how best to)?
I'm trying to implement a multi-room chat session, where users can join and leave rooms, but still missing exactly how to tell a group that a user should be added or removed from a room.
Reply to this email directly or view it on GitHub: https://github.com/Flotype/now/issues/33#issuecomment-2231849
510-691-3951 EECS Student at UC Berkeley http://ericzhang.com
Awesome, that helped alot. I was googling it but not quite understanding until you gave me that hint. I've now got groups working across all my rooms, with the group being joined by the client, but verified that they have membership by the server and then aligned to the group._id from the database. Yay!
Maybe this exists and I couldn't find it, but ...
Also, apologies. This is a feature request without any code to go with it... Lemme know if you'd prefer code...
Whenever I use a Socket.IO-esque framework, I need the server to be able to address the client directly. In NowJS, it looks as though the server can speak directly to the client only in response to a client connection.
Maybe, Google Analytics Async style, the client could pre-declare 'now' with a client_id (I've also added a roomID since it's :
Now the server can directly communicate with that client: