Reputation: 4808
It is possible to define (client-side): now.function = function(){console.log('test');}
... that is called by server using: everyone.function() - but can it be executed on specific client's browser only (using something like: everyone.onlyThisClient.function())?
It is possible to do that using this.now.function() in some cases (nowjs.on('connect'(...) for example) - but is it possible to do the same thing "outside" any other nowjs function/object?
Upvotes: 1
Views: 469
Reputation: 4808
I solved the issue by passing the clientId parameter and use it to call a function for specific user.
everyone.now.userRegister = function(params)
{
user.register(everyone, this.user.clientId, params);
};
(...)
var register = function(everyone, clientId, params)
{
nowjs.getClient(clientId, function()
{
this.now.afterUserRegister(false);
});
}
exports.register = register;
Note - this is just one approach to execute function "locally". It's also possible to pass a callback function and execute it - this way it is not necessary to use nowJS to run the after-something event.
Upvotes: 1