Hey everyone,
I am wondering if anybody has any wisdom for me on the following
issue. I am attempting to get variable syncing to work, but am having
difficulty doing so. The following is code that worked for me using
node 0.4.3 and Now 0.6.1. I recently updated to Node 0.6.6 and Now
0.7.6.
CLIENT
=========
now.receiveMessage = function(name, message, color){
$("#messages").append("<br><span style='color:" + color + ";'>" +
name + ": " + message + "</span>");
$("#leftside").scrollTop(1000000);
if(this.now.banned){
window.location = "/message/banned";
}else if(this.now.isPrivate){
location.hash = this.now.privateChatRoom;
}
}
SERVER
=========
everyone.now.changeRoom = function(newRoom){
this.now.isPrivate = false;
nowjs.getGroup(this.now.room).now.receiveMessage("SERVER",
this.now.name + " left the room.", "red");
nowjs.getGroup(this.now.room).removeUser(this.user.clientId);
nowjs.getGroup(newRoom).addUser(this.user.clientId);
this.now.room = newRoom;
userList[this.user.clientId]['room'] = this.now.room;
everyone.now.updateList(userList);
this.now.receiveMessage("SERVER", "You're now in " + this.now.room,
"red");
}
everyone.now.privateChatRequest = function(userId, userName){
userList[this.user.clientId]['room'] = userId;
userList[userId]['room'] = userId;
nowjs.getGroup(this.now.room).removeUser(this.user.clientId);
nowjs.getGroup(userId).addUser(this.user.clientId);
this.now.room = userId;
nowjs.getClient(userId, function(){
nowjs.getGroup(this.now.room).removeUser(this.user.clientId);
nowjs.getGroup(userId).addUser(this.user.clientId);
this.now.isPrivate = true;
this.now.privateChatRoom = userId;
this.now.room = userId;
this.now.receiveMessage("SERVER", "Your request for a private chat
has been granted. You are now speaking with an Admin.", "red");
});
everyone.now.updateList(userList);
this.now.receiveMessage("SERVER", "You're now in a private chat with
" + userName, "red");
}
I am particularly interested in the this.now.isPrivate variable. I
need to set it in order to properly update the client's URL hash. I
implemented the following code on the client, which did not work.
now.receiveMessage = function(name, message, color){
$("#messages").append("<br><span style='color:" + color + ";'>" +
name + ": " + message + "</span>");
$("#leftside").scrollTop(1000000);
if(this.now.banned){
window.location = "/message/banned";
}
now.ready(function(){
isItPrivate = this.now.isPrivate;
});
setTimeout(function(){
if(isItPrivate){
location.hash = this.now.privateChatRoom;
}
}, 1000);
}
Is there anything special on the server that needs to be done to set
that variable in order to reference it on the client side? I am at a
loss for the moment...