I have 3 components (1 server & 2 clients) executed in differents applications connected between IPCs. What I need is to know from server side what client is connected. I know the next Legato functions but I don’t know well how to use it:
le_msg_SessionRef_t sessionRef = 0;
sessionRef = MyServer_GetClientSessionRef();
uid_t clientUserId;
if (le_msg_GetClientUserId(sessionRef, &clientUserId) != LE_OK)
{
}
else
{
LE_INFO("My client has user ID %ud", clientUserId);
}
The difference is the sessionRef initialization.
But now I have another question. I’m trying to do the same in other application. This application is unsandboxed and I can’t get the ID (only if I put the application sandboxed). Is this a Legato limitation?
Note: MyServer component is running within an unsandboxed application.
So, at compilation time, I don’t have any errors but when I’m trying to execute the client (and server is running) this is the log file:
02:20:53 =ERR= | serviceDirectory[613]/serviceDirectory_exe T=main | serviceDirectory.c DispatchToServer() 739 | Client (uid 1012 'appMyClient', pid 28896) disagrees with server (uid 0 'root', pid 28561) on protocol ID of service 'MyClient'
02:20:53 *EMR* | MyClient[28896]/framework T=main | messagingSession.c ReceiveSessionOpenResponse() 735 | Unexpected server response (-5).
02:20:53 *CRT* | supervisor[608]/security T=main | app.c app_SigChildHandler() 1635 | The process 'MyClient' in app 'MyClient' has faulted and will be ignored in accordance with its fault policy.
What I’m doing wrong?
Note: I’m not using this function from the client side but myclient_interface.h file contains:
From the runtime error, there is a mismatch between the client and server. This error usually happens if you makes changes to the .api file but don’t update both the client and server. Did you rebuild and re-install both the client and the server?
Also, related to your original question, you said that the server needs to know which client is connected. What does it do with this information? Is it just for local data on the server, or for something else?
I don’t understand why could it be a rebuild error… because I have in my workspace the server component and the app which is linked and the same for the client component and app. So when I compile, I’m compiling all applications and components.
Regarding to the original question, this is needed because server will share different information depending on which client is connected or asking for data. Does it make sense?