Skip to main content
December 6, 2006
Question

call() all clients

  • December 6, 2006
  • 9 replies
  • 542 views
Is there a method should be used to call() all connected clients? Or do you set up a function to loop through Application.clients and perform Client.call() on each?
    This topic is closed to new replies. Start a new post to keep the conversation going.

    9 replies

    December 8, 2006
    Thanks, this is good information. I'll look into the SharedObject.purge, as well.
    December 8, 2006
    You a serversided non-persistent shared-object would be as easy or maybe even easier to implement ?

    1. you'd create a serversided SO
    2. you'd let your clients listen to the SS SO
    3. if anything would change in the SS SO then all clients would be notified immediately

    The main difference between a SS SO is that it's more or less multithreaded ; all clients are being updated at once. If you use a for-next loop then you'll always msg one client first and one client last which might be nasty if you want to distribute realtime data.
    December 8, 2006
    That's an interesting point, I hadn't thought about that. But the SO onSync wouldn't be exact either, would it? It would be varied for each client based on client latency, right? And the for loop would execute nearly instantly? And what about application.broadcastMsg(), is that multi-threaded?

    In my case, I am actually using a SO that clients are writing to directly and onSync, but sometimes I want to broadcast a message that all users get, but doesn't get recorded(either persistently or temporarily) so new users don't see that in the history.

    Another thing I'm trying to get a grasp on, is how to you use NetStream to send messages. For some reason that seems more attractive to me than using SOs. There are some things I don't want recorded in any way. Is NetStream faster than a SO? I've found the delay between SO write and other clients receiving the onSync change can be quite substantial, certainly too much for something that required realtime interaction, like a game.
    December 8, 2006
    The best solution to distribute realtime data to multiple clients is ofcourse totally depending on your own application, so true.

    You could use a SS SO with [SharedObject.purge()] ; to clean up old versions. It's a fact that new clients could be overwhelmed by "old" data when they connect. This might cause delays. If you purge old versions manually (e.g. after 10 updates?) your history won't be too long.

    Have a look at this configuration-node (in defRoot/defHost/Application.xml) : [ResyncDepth] ; though the docs are a bit unclear about:

    <!-- Deleted slots will be purged if the current version - deleted version is greater -->
    <!-- than the value specified. -->

    If I'm not incorrect this means that if you'd enter a number like [10] here then FMS wouldn't store more than 10 "changes" in the SS SO. I cannot confirm this yet. Maybe it's easy for you to test.

    Also do understand the laggy nature of internetconnections. When ppl have a latency/ping of say 100ms and you are sending a lot of data that might fillup their incoming or outgoing pipe then latency will increase.

    I wouldn't send more than 10 packets per second to any client to prevent a) client PC's from slowing down b) excessive bandwidth usage c) increase latency due to large packets.

    Besides all this SS SO talk I do agree with you that it is , from a programmers point of view , much more clear what happens when you create a simple for-next loop with the [application.clients] array.

    But when you have 100 clients in your instance and you need to run through 100 of them you can imagine that it would take some time to reach client #100 unless FMS really fires those 100 calls asynchronous.

    December 6, 2006
    Ah there we go, that's what I was looking for. Added in FMS apparently. Is there a "what's new" documentation somewhere on FMS vs. FCS? I can't for the life of me find anything. The livedocs don't seem to have the typical "What's new" section.
    December 6, 2006
    I never found a "What's new" section in help or in Livedoc... to bad it would been a useful thing. From developper view, FMS don't add a lot of new method if you don't use components.
    December 6, 2006
    Cool, that's what I wanted to know; thanks!
    December 6, 2006
    application.broadcastMsg(cmd [, p1, p2, ..., pN]) // only for FMS, doesn't work for FCS

    read the doc on this method....
    Inspiring
    December 6, 2006
    Hello :)

    in my work i use a HashMap to store all clients connected in the
    application.... (The HashMap class in in my SSAS framework : Vegas ->
    http://vegas.riaforge.org/)

    but you can uses application.clients object to launch the call() method
    for all users, in the documentation you can read the example :

    var len = application.clients.length ;

    for (var i = 0; i < len; i++)
    {
    application.clients .call("myCallMethod", null, value) ;
    }

    EKA+ :)



    abeall a écrit :
    > Is there a method should be used to call() all connected clients? Or do you set up a function to loop through Application.clients and perform Client.call() on each?