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


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 <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);

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; = (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

1 Like