Server & Client Components inside the same process


#1

Hi team,

I’m trying to execute a Server Component and a Client Component inside the same application and process following the documentation.
Documentation link:
http://www.legato.io/legato-docs/15_01_1/component_putting_into_app.html

Adapting documentation code to the ‘helloIpc’ example (obteined from devstudio), I’ve created this example:

executables:
{
    myServer = ( printServer )
    myClient = ( printClient )
}

processes:
{
    run:
    {
        (myServer)
        (myClient)
    }
}

bindings:
{
    myClient.printClient.printer -> myServer.printServer.printer
}

This code works properly and client asks for the running server and prints the information.

And this is what I’m trying to do:

executables:
{
    myApp = ( printServer printClient )
}

processes:
{
    run:
    {
        (myApp)
    }
}

bindings:
{
    myApp.printClient.printer -> myApp.printServer.printer
}

Note: printClient and printServer were extracted from the ‘helloIpc’ application example

In this case the client and server don’t work properly.

Is it possible to do this ‘merge’ in the same process?

Does it make sense?
I know what I’m asking is for a comunication between 2 components inside the same process. Because of the ‘requires’ (api) inside the client cdef file, if my .adef changes to this:

executables:
{
    myServer = ( printServer printClient )
}

processes:
{
    run:
    {
        (myServer)
    }
}

The compilation crashes with this error:

Description	Resource	Path	Location	Type
Client-side (required) interface 'myServer.printClient.printer' is unsatisfied.  It has not been declared an external (inter-app) required interface (in a "requires: api:" section in the .adef) and has not been bound to any service (in the "bindings:" section of the .adef).	IPCTest		line 13	C/C++ Problem

Thanks,

Daniel


#2

Hi, Daniel,

The problem is that you have taken out the binding, so the Service Directory doesn’t know what to connect the client side interface to.

All you need to do is add this to your .adef file:

bindings:
{
    myApp.printClient.printer -> myApp.printServer.printer
}

Cheers,

–Jen


#3

Hi, Jen,

Thanks for your support.

If I add the binding code to the .adef file (as it is showed in the second example):

[code]processes:
{
run:
{
(myApp)
}
}

bindings:
{
myApp.printClient.printer -> myApp.printServer.printer
}[/code]

Then the server and client components don’t run so, they don’t work properly. Also, I will need to add:

provides:{api:{ printer = myApp.printServer.printer}}

in order to provide the api to other client applications.