[Opa] Network.channel

Adam Koprowski Adam.Koprowski at mlstate.com
Thu Aug 18 10:04:27 EDT 2011


  Dear Mads,

  I'm not sure what you mean with Network creating singleton instances. On
the contrary: multiple calls to Network.empty() will create different
networks. Network.cloud(id) is supposed to create networks identified by
keys, so if you create networks with the same id on different servers
they'll be shared between the servers instead of creating two separate
networks (as long as you're using one server only, Network.cloud is not very
interesting)...
  So for creating ad-hoc networks just use Network.empy() or
Network.cloud(id) to share them between multiple servers.
  I suggest maybe you tell us a bit more about what you are trying to
achieve and then maybe we'll be able to better point you in the good
directions. Also I'll try to write a blog post about Sessions/Networks
(which are very important building blocks in Opa) within the next couple of
days, which should hopefully clarify things.

  Best,
  Adam

On Thu, Aug 18, 2011 at 01:33, Mads Jensen <mads379 at gmail.com> wrote:

> Hi guys,
>
> I have some questions regarding Network.channel. I want to create ad-hoc
> channel rather than the static ones in the chat example. The way I'm doing
> it right now is
> I'm cheating a channel with an id (as a string) and saving it in a
> UserContext. From the documentation I got the impression that the
> Network.channel would create
> 'singleton' like instances where that two consecutive calls to
> Network.cloud would return the same instance rather than creating two
> different ones.
>
> so my question is this: when I call Network.add_callback will it then be
> registered for "all" channels? Here's an example.
>
> channel = Network.cloud(name): Network.network(message)
> Network.add_callback(message_recieved, channel)
> UserContext.change(_ -> channel, state)
>
> .... later, somewhere else in another lexical scope .....
>
> channel = Network.cloud(name): Network.network(message)
> UserContext.change(_ -> channel, state)
>
> .... later again, somewhere else in another lexical scope .....
>
> channel = UserContext.execute( x -> x, state)
> channel.broadcast(..., channel) // will this get registrered by
> message_recieved?
>
> _______________________________________________
> Opa mailing list
> Opa at lists.owasp.org
> https://lists.owasp.org/mailman/listinfo/opa
>
>


-- 
*Adam Koprowski  [http://adam-koprowski.net]
R&D @ MLstate   [http://opalang.org | http://mlstate.com] *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.owasp.org/pipermail/opa/attachments/20110818/0534bdf4/attachment-0001.html 


More information about the Opa mailing list