Results 1 to 4 of 4
  1. #1

    Bidirectional I/O

    I'm considering using Lightstreamer to replace a simple framework I created for my node.js based application. The server to client I/O works great, but I also need to occasionally (aperiodic) send a simple object from the client to the server and a more complex object back from the server to the client. I'm currently using socket.io, but is there a better way to do this using the Lightstreamer API?

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    Lightstreamer does not directly handle objects:

    Server to client you send a list of name-value pairs;
    Client to server you send a string to be interpreted by the adapter.

    You can certainly wrap you objects doing a JSON stringify but, for the server to client case, it is better to stick as much as possible to the name-value pairs to gain in performance.

    We have several examples that show bi-directional communication using Lightstreamer, the simplest one is probably the Chat demo:

    Adapter: https://github.com/Weswit/Lightstrea...t-adapter-java
    Client: https://github.com/Weswit/Lightstrea...ent-javascript

    (if you prefer to keep JavaScript on the server-side take a look at this: https://github.com/Weswit/Lightstrea...t-adapter-node )

  3. #3
    Converting it to a JSON string worked. But I want to make sure I'm using this tool correctly. My client needs to build command forms from the command definitions on the server. It only does this when it first loads the page. After that, the server pushes key-value pairs at a high rate. Would it be better to continue using Lightstreamer for all the data and command definition IO, or should I let the web server push command definitions itself?

  4. #4
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    I'm not sure the meaning of "command form", is it form as in <form>?

    If you think to build the page server side (i.e. the client receives the page already containing the "command forms") then that may be faster as the client doesn't need to wait for the Lightstreamer connection and can be directly rendered. If you don' mind about this you can push such data through Lightstreamer.

    If such forms may change during the life of the page, making the data go through Lightstreamer is the best choice.

    If the data is only fetched once (either via xhr or via Lightstreamer) then it just depends on what's handier for you.

    HTH

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 12:17 PM.