Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Ajay.Gov
    @ajay-gov
    @vishnuprasad73_twitter is the node ws library(https://www.npmjs.com/package/ws) one of the dependencies in your node application? If so can you try without having that as a dependency?
    Vishnu Prassad
    @vishnuprasad73_twitter
    @ajay-gov I don't use the WS library in the client app. My whole node client is the 8 lines of code i mentioned above. But i can see ws library inside node_modules when i install @swim/client
    Ajay.Gov
    @ajay-gov
    oh ok, so it's that websocket library from node which the swim-client is depending on.
    Do try it from the browser when you get a chance. We will fix that issue with the swim-client and node.
    Vishnu Prassad
    @vishnuprasad73_twitter
    Sure will do and update
    Ajay.Gov
    @ajay-gov
    @vishnuprasad73_twitter thanks! Also which version of the swim-server library are you using on the server-side. You may get that from the build.gradle and gradle.properties file.
    @vishnuprasad73_twitter we fixed a similar issue in February. Please check swimos/swim#48. It is available in our latest release version of the swim-server library which is 3.10.2.
    Vishnu Prassad
    @vishnuprasad73_twitter
    @ajay-gov im using these versions
    compile group: 'org.swimos', name: 'swim-server', version: '3.10.0'
    compile group: 'org.swimos', name: 'swim-api', version: '3.10.0'
    compile group: 'org.swimos', name: 'swim-client', version: '3.10.0'
    i will try 3.10.2 and update
    @ajay-gov Just tried updating to 3.10.2 and it worked like a charm!!!
    And with that, I have successfully implemented a hello world app on SWIM :)
    Thanks a lot
    Vishnu Prassad
    @vishnuprasad73_twitter
    Btw on maven repo the latest version is 3.10.0. people might not be aware of 3.10.2
    Ajay.Gov
    @ajay-gov
    @vishnuprasad73_twitter great to know it worked!
    So we moved our namespace from ai.swim to org.swimos. org. The latest version for org.swimos should be 3.10.2 (https://mvnrepository.com/artifact/org.swimos/swim-server)
    Latest version for ai.swim is 3.10.0 (https://mvnrepository.com/artifact/ai.swim/swim-server). Going forward we will be using org.swimos.
    Vishnu Prassad
    @vishnuprasad73_twitter
    Ah Got it.
    nmehta1993
    @nmehta1993
    any one help me to setup swim
    api
    brohitbrose
    @brohitbrose
    Hi, could you please be a little more specific?
    Are you trying to get a Swim application working on your machine for the first time? Then we recommend the tutorial application on Github: https://github.com/swimos/tutorial
    If you're trying to architect Web Agents / Lanes (i.e. a Swim API) to solve a problem, then we recommend reading these cookbooks: https://www.swimos.org/tutorials/ . Or, we can help you further if you tell us your specific problem.
    Vishnu Prassad
    @vishnuprasad73_twitter
    let valueLane = client.downlinkValue()
                        .hostUri("warp://localhost:9001").nodeUri("/welcome/valueLane").laneUri("info")
                        .open();
    
    valueLane.set(structure.Text.from("YYY"));
    Once i open a connection to a valueLane how can i close it. Trying with nodejs
    i was able to send a message to value lane
    brohitbrose
    @brohitbrose
    valueLane.close(); should work from node client
    Vishnu Prassad
    @vishnuprasad73_twitter
    @brohitbrose Thanks
    Vishnu Prassad
    @vishnuprasad73_twitter
    Can someone give me a real-world example of how SWIM is faster than traditional REST APIs or apps? I want to do POC to show how SWIM is faster than traditional REST based apps.
    Ajay.Gov
    @ajay-gov
    @vishnuprasad73_twitter Swim is a stateful platform for Real-Time Applications at scale. Swim provides Stateful Services (Web Agents), Streaming (using WARP) APIs and Real-time UIs (swim UI toolkit).
    For example you can take a look at the traffic (https://github.com/swimos/traffic), here changes to the state of an intersection (red/green/yellow) is propagated from the intersection to the cloud and then to your browser within 100 milliseconds and this is done for over a hundred intersections.
    Similarly you can take a look at the traffic (https://github.com/swimos/transit), here changes to the location of buses is propagated from the bus to the cloud and then to your browser within 100 milliseconds and this is done for over 8000 buses.
    Doing this with REST would involve polling endlessly from the browser for each intersection/bus which will overload the server and the browser.
    The traffic and transit are just sample applications. We have customers that use swim in production at a much larger scale. Please look here for a brief summary of some of our customer applications- https://www.swim.ai/customers/
    Vishnu Prassad
    @vishnuprasad73_twitter
    @ajay-gov Thanks for the detailed info. I'm working on an e-commerce platform. Can you tell me how swim ai will be useful in e-commerce , can u suggest some use cases ?
    Ajay.Gov
    @ajay-gov
    @vishnuprasad73_twitter swimOS can be used for all use-cases in the e-commerce platform that require real-time processing with stateful entities. First thing to do would be to model your application using Web Agents, a simple start would be to have a WebAgent for each User, Product(item with a serial number) and a ProductType. You could then compute real-time analytics at each level
    • At the User WebAgent level you could analyze the pattern (using some algorithm) of purchases made by a user to build a real-time profile of a user that gets updated on every purchase . This may help in promoting the right types of Products for this user
    • At the Product WebAgent level you could get real-time metrics eg: how many purchases were made (raw number), purchases made by state/country (if you have the user's location info). You could have time-series for these as well. This maybe useful to determine the general trends for when a product gets bought.
    • At the ProductType WebAgent level it is similar to the ProductWebAgent except you can compute these real-time metrics for each ProductType
    These are just some ideas. I'm sure you can come up with more scenarios based on your application.
    Vishnu Prassad
    @vishnuprasad73_twitter
    @ajay-gov thanks for the detailed explanation
    var swim = require("@swim/client");
    var structure = require("@swim/structure");
    
    const client = new swim.WarpClient();
    
    let valueLane = client.downlinkValue()
                        .hostUri("warp://localhost:9001").nodeUri("/welcome/user").laneUri("info")
                        .didSet((newValue, oldValue) => {
                            console.log("link watched info change to " + newValue + " from " + oldValue);
                          })
                        .open();
    
    let oldvalue = valueLane.get()
    
    valueLane.set("john");
    
    console.log(oldvalue)
    
    client.close()
    Im trying to work with value lane. above is the client code. When i run the code the old value comes
    as empty (link watched info change to john from Value.absent()). Am i missing anything here. i can see the old and new value in the server side log
    and console.log(oldvalue) returns Absent {}
    Scott Clarke
    @scottswim
    what data type is your info lane (String or Value)? Based on the name I am guessing that you have a Value lane but are sending a String. If you are sending to a Value lane, then use valuelane.set(swim.Value.fromAny("john")) instead. This will convert your string to a Swim Value.
    Ajay.Gov
    @ajay-gov
    @vishnuprasad73_twitter the oldValue is being assigned before you call valueLane.set. So the oldValue has the initial value of the valueLane which is Absent (indicates that it is absent).
    let oldvalue = valueLane.get();
    valueLane.set("john");
    console.log(oldvalue);
    oldvalue = valueLane.get();
    console.log(oldvalue);
    This should print Absent and then "john".
    valueLane.get() returns the current value of that valueLane()
    Vishnu Prassad
    @vishnuprasad73_twitter

    @ajay-gov got it. what im trying to achieve is, to get the old and new value on the client side.

    on the server side,

      @SwimLane("info")
      ValueLane<String> info = this.<String>valueLane()
          .didSet((newValue, oldValue) -> {
            logMessage("`info` set to " + newValue + " from " + oldValue);
          });

    this prints the old and new value every time i set a new value. like this, [/welcome/user]infoset to hello from world

    but on client side,

    .didSet((newValue, oldValue) => {
                            console.log("link watched info change to " + newValue + " from " + oldValue);
                          })

    this always comes as absent.

    Maybe I'm understanding the purpose of value lane incorrectly?

    Vishnu Prassad
    @vishnuprasad73_twitter
    is there a way to get the current remote state? that i can show as old value while setting new value
    Ajay.Gov
    @ajay-gov

    @vishnuprasad73_twitter

    const client = new swim.WarpClient();
    
    let valueLane = client.downlinkValue()
                        .hostUri("warp://localhost:9001").nodeUri("/welcome/user").laneUri("info")
                        .didSet((newValue, oldValue) => {
                            console.log("link watched info change to " + newValue + " from " + oldValue);
                          })
                        .open();

    is all you need. Whenever the "info" lane for the node "/welcome/user" gets updated on the server then the didSet callback in the valueLane reference in the client should get invoked with the oldValue and the newValue. Are you not seeing this?

    Vishnu Prassad
    @vishnuprasad73_twitter

    @ajay-gov i tried that. but when i set a new value, the callback im getting on the client side is,
    link watched info change to john from Value.absent()

    i have the same callback on server side, which works correctly.

    @SwimLane("info")
      ValueLane<String> info = this.<String>valueLane()
          .didSet((newValue, oldValue) -> {
            logMessage("`info` set to " + newValue + " from " + oldValue);
          });

    which logs out put as below,

    [/welcome/user] `info` set to doe from john

    i tried setting the value as @scottswim mentioned above, valuelane.set(swim.Value.fromAny("john")) still it shows as absent on client side though
    Ajay.Gov
    @ajay-gov
    hmm..strange that it's not working. How are you setting the value lane i.e is it done on the server side? Also hopefully you are not calling client.close() before the value lane gets set.
    Vishnu Prassad
    @vishnuprasad73_twitter
    Ohhh!. I was calling client.close() at the end of the code!. Removed it and now i can see the old value though.
    @ajay-gov
    Ajay.Gov
    @ajay-gov
    @vishnuprasad73_twitter Great, so it works now?
    Vishnu Prassad
    @vishnuprasad73_twitter
    Yes. Thank a lot.
    Vishnu Prassad
    @vishnuprasad73_twitter
    @ajay-gov Do you know any services or any simulator which provides sample IoT data which i can use and play around with swim ?
    Ajay.Gov
    @ajay-gov
    Sure, glad to hear that it works. A bit more detail- when you open a downlink the swim client establishes a connection to the server. The data is streamed from the server to the client using that connection. You may open multiple downlinks i.e to other nodes/lanes on the same host and the swim client will use the same connection to stream data to the different downlinks. However when you call client.close the connection to the server is closed and all downlinks will stop getting the data from the server.