Sending User Data to Server Apps

Hello all,

I have tried doing the example in the documentation for cloudxr 2.0, I have not been able to get it working thus far. I am just running a simple C++ program on the server side to get the memory mapped file, I get an error code of

ERROR_FILE_NOT_FOUND

2 (0x2)

The system cannot find the file specified.

I have got the name of the mutex and the file from the CloudXR client on windows in the CloudXRCommon.h header file.

const char* const cxrUserDataFileName = “CloudXR User Data”;
const char* const cxrUserDataMutexName = “CloudXR User Data Mutex”;

The code is below for the simple “server” application:

#include //"< string > "
#include
#include <windows.h>
const uint32_t cxrUserDataMaxSize = 8 * 1024;
const char* const cxrUserDataFileName = “CloudXR User Data”;
int main() {
HANDLE hUserDataFile = OpenFileMapping(FILE_MAP_READ, FALSE, LPWSTR("\Sessions\1\BaseNamedObjects\CloudXR User Data"));
std::cout << GetLastError();
unsigned char* mappedUserData = (unsigned char*)MapViewOfFile(hUserDataFile, FILE_MAP_READ, 0, 0, cxrUserDataMaxSize); //cxrUserDataMaxSize
HANDLE hUserDataMutex = CreateMutex(NULL, FALSE, LPCWSTR(“CloudXR User Data Mutex”));
for (int i = 0; i < 1000; i++)
{
WaitForSingleObject(hUserDataMutex, INFINITE);
printf_s("%.*s\n", cxrUserDataMaxSize, mappedUserData);
ReleaseMutex(hUserDataMutex);
Sleep(500);
}
UnmapViewOfFile(mappedUserData);
CloseHandle(hUserDataFile);
}

I have also used process explorer and the files seem to be there. Is there something simple I am missing here?

I am using the windows client utlising this small section of code to send custom data:

if (options.mUserData.size())
{
cxrInputEvent event;
event.type = cxrInputEventType_Generic;
event.event.genericInputEvent.data = (uint8_t*)&options.mUserData[0];
event.event.genericInputEvent.sizeInBytes = (uint32_t)options.mUserData.size() + 1;
cxrSendInputEvent(receiver, &event);
}

The issue was I did not use L"< stringpath >" on the call:
HANDLE hUserDataFile = OpenFileMapping(FILE_MAP_READ, FALSE, LPWSTR(L"CloudXR User Data")); it need to be a widechar literal

2 Likes

For me I can find only “CloudXR User Data Mutex” in Process Explorer… Should I do something else to see “CloudXR User Data” file?
In the server App I could not find it either

Hi @a.shevchenko - Can you please expand on what your use case is?

Thanks!

Veronica

Hi Veronica,
thank you for your reply, the problem is already solved :) I just didn’t know that I should send the “cxrInputEventType_Generic” event. I thought that the file will be just there when I start the connection