This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How do you send data between light_server and light_server?

Now I'm done from send data to the light_client light_service, but I don't know how to send data to another light_server let light_server, I look at the related documents, find it mentioned elements and model, according to the test with me at the console output, now I think I need a model that is added in the two light_server let they bind to each other. Am I right now? I would be grateful if you could make Suggestions or other better methods.

Parents
  • Hi Libo,

    The role of server and client and control model is defined in spec as follow:

    • Server model: A server model is composed of one or more states spanning one or more elements. The server model defines a set of mandatory messages that it can transmit or receive, the behavior required of the element when it transmits and receives such messages, and any additional behavior that occurs after messages are transmitted or received.

    • Client model: A client model defines a set of messages (both mandatory and optional) that a client uses to request, change, or consume corresponding server states, as defined by a server model. The client model does not have state.

    • Control model: A control model may contain client model functionality to communicate with other server models and server model functionality to communicate with other client models. A control model may also contain control logic, which is a set of rules and behaviors that coordinate the interactions between other models that the control model connects to.

    What you want to do maybe more fit into a Control Model.

    This mean you need to implement a Client on the server node to request, or set data on the peer server.

    By spec, there is only one publication address per element. So you need to change the publication address on the element to make it able to send data to other server.

    Another option is to skip the client-server model, and base the application on top of access layer.

    You can use the following APIs:

    • dsm_local_unicast_addresses_get() get the element own unicast address.

    • dsm_address_publish_add() add a publication address in to database.

    • access_model_publish_address_set() set the publication database

    • access_model_publish() send a message

    • access_model_reliable_publish() send a reliable message

  • Hi,

    I want to same data transfer between light server to light server. So the above API need to use but i confused how i can configure the above API in existing server code. In which function i need to call this API. Can you provide me example for the same. 

    Thanks.... 

  • We don't have an example for now. Also accessing the access layer without using server/client model is not suggested by the spec as it limit the inter-operability of the network . 

    It's the best is to implement a client on the same node as the server and use that client to send data. (2 elements on one node)

    If you still want to use access layer directly, I would suggest you to have a look at the light switch client to see how a message is sent when you press the button. You then can apply the same on your server, but you need to change the publication address.

Reply
  • We don't have an example for now. Also accessing the access layer without using server/client model is not suggested by the spec as it limit the inter-operability of the network . 

    It's the best is to implement a client on the same node as the server and use that client to send data. (2 elements on one node)

    If you still want to use access layer directly, I would suggest you to have a look at the light switch client to see how a message is sent when you press the button. You then can apply the same on your server, but you need to change the publication address.

Children
No Data
Related