Re: [NowJS] Quick question: Can clients retrieve variables stored in the now magic pocket?

47 views
Skip to first unread message

Ian Serlin

unread,
Jun 15, 2012, 3:12:04 PM6/15/12
to no...@googlegroups.com
Hi Orthonormal,

Values you place into the magic pocket get automatically synced across clients and the server and are available to all of them. If you run your example and then open the console in Chrome, for instance, you would be able to type "now.foo" and see that it has the value "bar".

You can place variables in only one client's this.now pocket if you want, but really if you want to have values that are only known to the server you should keep them in a different server variable outside of the now magic pockets.

Hope that helps!

Ian Serlin
Owner Useful IO LLC



On Fri, Jun 15, 2012 at 7:17 AM, Orthonormal <s.cov...@gmail.com> wrote:
 // Server side
 everyone.now.setValue = function() {
      this.now.foo = 'bar';
 }
 // Client side
 <script>
 now.ready(function(){
   now.setValue();
 });

Is the client able to get the value of foo without me allowing him to?

Example: If this was a poker game, I might sync an array containing everyone's cards in the magic pocket. Would a player be able to cheat and retrieve the values in the array in order to know what cards everyone is holding?

Orthonormal

unread,
Sep 23, 2012, 6:09:43 PM9/23/12
to no...@googlegroups.com
Sorry about the very late reply. But yes, this was VERY useful information! Thanks!
Reply all
Reply to author
Forward
0 new messages