Message from discussion
Group.now not synced?
Received: by 10.52.69.241 with SMTP id h17mr30594994vdu.5.1341819227272;
Mon, 09 Jul 2012 00:33:47 -0700 (PDT)
X-BeenThere: nowjs@googlegroups.com
Received: by 10.220.223.77 with SMTP id ij13ls4987vcb.1.gmail; Mon, 09 Jul
2012 00:33:46 -0700 (PDT)
Received: by 10.52.23.65 with SMTP id k1mr930633vdf.7.1341819226887;
Mon, 09 Jul 2012 00:33:46 -0700 (PDT)
Date: Mon, 9 Jul 2012 00:33:46 -0700 (PDT)
From: Ben Corne <ben.co...@gmail.com>
To: nowjs@googlegroups.com
Message-Id: <2fc8b1e7-2ee0-44dc-b546-116d85e8dca4@googlegroups.com>
In-Reply-To: <7824aef8-ce66-47b7-bbc2-9e18e43c58e3@googlegroups.com>
References: <7824aef8-ce66-47b7-bbc2-9e18e43c58e3@googlegroups.com>
Subject: Re: Group.now not synced?
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_1062_779438.1341819226593"
------=_Part_1062_779438.1341819226593
Content-Type: multipart/alternative;
boundary="----=_Part_1063_13797546.1341819226593"
------=_Part_1063_13797546.1341819226593
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
A bit of clarification:
The example from examples/multiroomchat_example
-----------------
everyone.now.changeRoom = function(newRoom){
this.now.distributeMessage("[leaving " + this.now.room + "]");
nowjs.getGroup(this.now.room).removeUser(this.user.clientId);
nowjs.getGroup(newRoom).addUser(this.user.clientId);
this.now.room = newRoom;
this.now.distributeMessage("[entering " + this.now.room + "]");
var that = this;
nowjs.getGroup(this.now.room).count(function(count){
var prettyCount = (count === 1) ? "Room is empty." : (count - 1) + " other(s) in room.";
that.now.receiveMessage("SERVER", "You're now in " + that.now.room + ". " + prettyCount);
});
}
everyone.now.distributeMessage = function(message){
nowjs.getGroup(this.now.room).now.receiveMessage(this.now.name, message);
};
-------------------
To me, this means that a group object's now should be able to perform now
calls just like on the everyone group.
I'm building a smaller example than the one I'm working on so I can share
easily.
On Saturday, July 7, 2012 12:37:39 PM UTC+2, Ben Corne wrote:
>
> Hello again
>
> This time I'm here with a question regarding group's .now property.
>
> Here's the scenario:
> A user logs in, sits in the lobby and joins a room.
> This operation adds him to the now.js#Group of the room, emitting a join
> event by now.js itself;
> This event is captured and the group is notified of a new group member:
> mygroup.now.receiveRoomMessage(user.name+' joined the room.')
>
> On the client side, the now object has getters and setters for
> receiveRoomMessage, however, when I log the serverside group's now:
> console.log(mygroup.now) it always prints an empty object.
> After multiple joins it still stays empty so it's not like the method
> isn't propagated yet.
>
> Any clues?
>
> Kind regards
> Ben
>
------=_Part_1063_13797546.1341819226593
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<div>A bit of clarification:</div>The example from examples/multiroomchat_e=
xample<div>-----------------<br><div><pre style=3D"font-size: 12px; font-fa=
mily: Consolas, Menlo, 'Liberation Mono', Courier, monospace; color: rgb(51=
, 51, 51); line-height: 16px; "><div class=3D"line" id=3D"LC27" style=3D"pa=
dding-left: 10px; "><span class=3D"nx">everyone</span><span class=3D"p">.</=
span><span class=3D"nx">now</span><span class=3D"p">.</span><span class=3D"=
nx">changeRoom</span> <span class=3D"o" style=3D"font-weight: bold; ">=3D</=
span> <span class=3D"kd" style=3D"font-weight: bold; ">function</span><span=
class=3D"p">(</span><span class=3D"nx">newRoom</span><span class=3D"p">){<=
/span></div><div class=3D"line" id=3D"LC28" style=3D"padding-left: 10px; ">=
<span class=3D"k" style=3D"font-weight: bold; ">this</span><spa=
n class=3D"p">.</span><span class=3D"nx">now</span><span class=3D"p">.</spa=
n><span class=3D"nx">distributeMessage</span><span class=3D"p">(</span><spa=
n class=3D"s2" style=3D"color: rgb(221, 17, 68); ">"[leaving "</span> <span=
class=3D"o" style=3D"font-weight: bold; ">+</span> <span class=3D"k" style=
=3D"font-weight: bold; ">this</span><span class=3D"p">.</span><span class=
=3D"nx">now</span><span class=3D"p">.</span><span class=3D"nx">room</span> =
<span class=3D"o" style=3D"font-weight: bold; ">+</span> <span class=3D"s2"=
style=3D"color: rgb(221, 17, 68); ">"]"</span><span class=3D"p">);</span><=
/div><div class=3D"line" id=3D"LC29" style=3D"padding-left: 10px; "> &=
nbsp;<span class=3D"nx">nowjs</span><span class=3D"p">.</span><span class=
=3D"nx">getGroup</span><span class=3D"p">(</span><span class=3D"k" style=3D=
"font-weight: bold; ">this</span><span class=3D"p">.</span><span class=3D"n=
x">now</span><span class=3D"p">.</span><span class=3D"nx">room</span><span =
class=3D"p">).</span><span class=3D"nx">removeUser</span><span class=3D"p">=
(</span><span class=3D"k" style=3D"font-weight: bold; ">this</span><span cl=
ass=3D"p">.</span><span class=3D"nx">user</span><span class=3D"p">.</span><=
span class=3D"nx">clientId</span><span class=3D"p">);</span></div><div clas=
s=3D"line" id=3D"LC30" style=3D"padding-left: 10px; "> <span cla=
ss=3D"nx">nowjs</span><span class=3D"p">.</span><span class=3D"nx">getGroup=
</span><span class=3D"p">(</span><span class=3D"nx">newRoom</span><span cla=
ss=3D"p">).</span><span class=3D"nx">addUser</span><span class=3D"p">(</spa=
n><span class=3D"k" style=3D"font-weight: bold; ">this</span><span class=3D=
"p">.</span><span class=3D"nx">user</span><span class=3D"p">.</span><span c=
lass=3D"nx">clientId</span><span class=3D"p">);</span></div><div class=3D"l=
ine" id=3D"LC31" style=3D"padding-left: 10px; "> <span class=3D"=
k" style=3D"font-weight: bold; ">this</span><span class=3D"p">.</span><span=
class=3D"nx">now</span><span class=3D"p">.</span><span class=3D"nx">room</=
span> <span class=3D"o" style=3D"font-weight: bold; ">=3D</span> <span clas=
s=3D"nx">newRoom</span><span class=3D"p">;</span></div><div class=3D"line" =
id=3D"LC32" style=3D"padding-left: 10px; "> <span class=3D"k" st=
yle=3D"font-weight: bold; ">this</span><span class=3D"p">.</span><span clas=
s=3D"nx">now</span><span class=3D"p">.</span><span class=3D"nx">distributeM=
essage</span><span class=3D"p">(</span><span class=3D"s2" style=3D"color: r=
gb(221, 17, 68); ">"[entering "</span> <span class=3D"o" style=3D"font-weig=
ht: bold; ">+</span> <span class=3D"k" style=3D"font-weight: bold; ">this</=
span><span class=3D"p">.</span><span class=3D"nx">now</span><span class=3D"=
p">.</span><span class=3D"nx">room</span> <span class=3D"o" style=3D"font-w=
eight: bold; ">+</span> <span class=3D"s2" style=3D"color: rgb(221, 17, 68)=
; ">"]"</span><span class=3D"p">);</span></div><div class=3D"line" id=3D"LC=
33" style=3D"padding-left: 10px; "> <span class=3D"kd" style=3D"=
font-weight: bold; ">var</span> <span class=3D"nx">that</span> <span class=
=3D"o" style=3D"font-weight: bold; ">=3D</span> <span class=3D"k" style=3D"=
font-weight: bold; ">this</span><span class=3D"p">;</span></div><div class=
=3D"line" id=3D"LC34" style=3D"padding-left: 10px; "> <span clas=
s=3D"nx">nowjs</span><span class=3D"p">.</span><span class=3D"nx">getGroup<=
/span><span class=3D"p">(</span><span class=3D"k" style=3D"font-weight: bol=
d; ">this</span><span class=3D"p">.</span><span class=3D"nx">now</span><spa=
n class=3D"p">.</span><span class=3D"nx">room</span><span class=3D"p">).</s=
pan><span class=3D"nx">count</span><span class=3D"p">(</span><span class=3D=
"kd" style=3D"font-weight: bold; ">function</span><span class=3D"p">(</span=
><span class=3D"nx">count</span><span class=3D"p">){</span></div><div class=
=3D"line" id=3D"LC35" style=3D"padding-left: 10px; "> &nbs=
p;<span class=3D"kd" style=3D"font-weight: bold; ">var</span> <span class=
=3D"nx">prettyCount</span> <span class=3D"o" style=3D"font-weight: bold; ">=
=3D</span> <span class=3D"p">(</span><span class=3D"nx">count</span> <span =
class=3D"o" style=3D"font-weight: bold; ">=3D=3D=3D</span> <span class=3D"m=
i" style=3D"color: rgb(0, 153, 153); ">1</span><span class=3D"p">)</span> <=
span class=3D"o" style=3D"font-weight: bold; ">?</span> <span class=3D"s2" =
style=3D"color: rgb(221, 17, 68); ">"Room is empty."</span> <span class=3D"=
o" style=3D"font-weight: bold; ">:</span> <span class=3D"p">(</span><span c=
lass=3D"nx">count</span> <span class=3D"o" style=3D"font-weight: bold; ">-<=
/span> <span class=3D"mi" style=3D"color: rgb(0, 153, 153); ">1</span><span=
class=3D"p">)</span> <span class=3D"o" style=3D"font-weight: bold; ">+</sp=
an> <span class=3D"s2" style=3D"color: rgb(221, 17, 68); ">" other(s) in ro=
om."</span><span class=3D"p">;</span></div><div class=3D"line" id=3D"LC36" =
style=3D"padding-left: 10px; "> <span class=3D"nx">t=
hat</span><span class=3D"p">.</span><span class=3D"nx">now</span><span clas=
s=3D"p">.</span><span class=3D"nx">receiveMessage</span><span class=3D"p">(=
</span><span class=3D"s2" style=3D"color: rgb(221, 17, 68); ">"SERVER"</spa=
n><span class=3D"p">,</span> <span class=3D"s2" style=3D"color: rgb(221, 17=
, 68); ">"You're now in "</span> <span class=3D"o" style=3D"font-weight: bo=
ld; ">+</span> <span class=3D"nx">that</span><span class=3D"p">.</span><spa=
n class=3D"nx">now</span><span class=3D"p">.</span><span class=3D"nx">room<=
/span> <span class=3D"o" style=3D"font-weight: bold; ">+</span> <span class=
=3D"s2" style=3D"color: rgb(221, 17, 68); ">". "</span> <span class=3D"o" s=
tyle=3D"font-weight: bold; ">+</span> <span class=3D"nx">prettyCount</span>=
<span class=3D"p">);</span></div><div class=3D"line" id=3D"LC37" style=3D"p=
adding-left: 10px; "> <span class=3D"p">});</span></div><div cla=
ss=3D"line" id=3D"LC38" style=3D"padding-left: 10px; "><span class=3D"p">}<=
/span></div><div class=3D"line" id=3D"LC39" style=3D"padding-left: 10px; ">=
<br></div><div class=3D"line" id=3D"LC40" style=3D"padding-left: 10px; "><s=
pan class=3D"nx">everyone</span><span class=3D"p">.</span><span class=3D"nx=
">now</span><span class=3D"p">.</span><span class=3D"nx">distributeMessage<=
/span> <span class=3D"o" style=3D"font-weight: bold; ">=3D</span> <span cla=
ss=3D"kd" style=3D"font-weight: bold; ">function</span><span class=3D"p">(<=
/span><span class=3D"nx">message</span><span class=3D"p">){</span></div><di=
v class=3D"line" id=3D"LC41" style=3D"padding-left: 10px; "> <sp=
an class=3D"nx">nowjs</span><span class=3D"p">.</span><span class=3D"nx">ge=
tGroup</span><span class=3D"p">(</span><span class=3D"k" style=3D"font-weig=
ht: bold; ">this</span><span class=3D"p">.</span><span class=3D"nx">now</sp=
an><span class=3D"p">.</span><span class=3D"nx">room</span><span class=3D"p=
">).</span><span class=3D"nx">now</span><span class=3D"p">.</span><span cla=
ss=3D"nx">receiveMessage</span><span class=3D"p">(</span><span class=3D"k" =
style=3D"font-weight: bold; ">this</span><span class=3D"p">.</span><span cl=
ass=3D"nx">now</span><span class=3D"p">.</span><span class=3D"nx">name</spa=
n><span class=3D"p">,</span> <span class=3D"nx">message</span><span class=
=3D"p">);</span></div><div class=3D"line" id=3D"LC42" style=3D"padding-left=
: 10px; "><span class=3D"p">};</span></div></pre><div>-------------------<b=
r></div><div>To me, this means that a group object's now should be able to =
perform now calls just like on the everyone group.</div><div><br></div><div=
>I'm building a smaller example than the one I'm working on so I can share =
easily.</div><br>On Saturday, July 7, 2012 12:37:39 PM UTC+2, Ben Corne wro=
te:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;">Hello again<div><br></div><=
div>This time I'm here with a question regarding group's .now property.<br>=
<br>Here's the scenario:</div><div>A user logs in, sits in the lobby and jo=
ins a room.</div><div>This operation adds him to the now.js#Group of the ro=
om, emitting a join event by now.js itself;</div><div>This event is capture=
d and the group is notified of a new group member: mygroup.now.<wbr>receive=
RoomMessage(<a href=3D"http://user.name" target=3D"_blank">user.name</a>+' =
joined the room.')</div><div><br></div><div>On the client side, the now obj=
ect has getters and setters for receiveRoomMessage, however, when I log the=
serverside group's now: console.log(mygroup.now) it always prints an empty=
object.</div><div>After multiple joins it still stays empty so it's not li=
ke the method isn't propagated yet.</div><div><br></div><div>Any clues?</di=
v><div><br></div><div>Kind regards</div><div>Ben</div></blockquote></div></=
div>
------=_Part_1063_13797546.1341819226593--
------=_Part_1062_779438.1341819226593--