Putting an Array into a ExitGames::Common::Hashtable
Hello,
This is for a photon cloud c ++ Android client.
I created a Hashtable like this:
I created a JVector like this:
When I do this:
I get compile errors:
I suspect that a ExitGames::Common:Hashtable doesn’t permit a JVector as a value object. If yes, then how do I put an array into a ExitGames::Common:Hashtable?
Thanks.
This is for a photon cloud c ++ Android client.
I created a Hashtable like this:
ExitGames::Common::Hashtable data = ExitGames::Common::Hashtable();
I created a JVector like this:
ExitGames::Common::JVector<ExitGames::Common::Hashtable> playerArray;
When I do this:
data.put("key", playerArray);
I get compile errors:
error: no member named 'TypeCode' in 'ExitGames::Common::JVector<ExitGames::Common::Hashtable>' COMPILE_TIME_ASSERT_TRUE_MSG((IsDerivedFrom<CType, CustomType<CType::TypeCode> >::Is), ERROR_UNSUPPORTED_VALUE_TYPE);
I suspect that a ExitGames::Common:Hashtable doesn’t permit a JVector as a value object. If yes, then how do I put an array into a ExitGames::Common:Hashtable?
Thanks.
0
Best Answer
-
Hi @GreenRollingHills.
Yes, that is correct. You can't put a JVector into a Hashtable.
However you can put a C array into a Hashtable and hence you can put the content of a JVector into a Hashtable like this:ExitGames::Common::Hashtable data; ExitGames::Common::JVector<ExitGames::Common::Hashtable> playerArray; data.put(L"key", playerArray.getCArray(), playerArray.getSize());
PS:ExitGames::Common::Hashtable data = ExitGames::Common::Hashtable();
That lines creates an empty Hashtable just to then immediately assign the content of another tomporarily created empty Hashtable to it, which is rather pointless.
You can instead simply writeExitGames::Common::Hashtable data;
like I did in the above sample code.
PPS:
Also I changed"key"
toL"key". by passing a wide string literal in the first place, this saves the conversion from narrow string to wide string that would appear in your code.
PPPS:
Are you aware of demo_typeSupport inside the Client SDKs demo folder?
CPhotonLib::sendData() in the code of that demo demonstrates how to send various types of data and among other things it also puts various arrays into a Hashtable.
For questions like this having a look at that demo makes sense so that you can figure it out immediately by yourself and don't have to wait until you get an answer in the forum.5
Answers
-
Hi @GreenRollingHills.
Yes, that is correct. You can't put a JVector into a Hashtable.
However you can put a C array into a Hashtable and hence you can put the content of a JVector into a Hashtable like this:ExitGames::Common::Hashtable data; ExitGames::Common::JVector<ExitGames::Common::Hashtable> playerArray; data.put(L"key", playerArray.getCArray(), playerArray.getSize());
PS:ExitGames::Common::Hashtable data = ExitGames::Common::Hashtable();
That lines creates an empty Hashtable just to then immediately assign the content of another tomporarily created empty Hashtable to it, which is rather pointless.
You can instead simply writeExitGames::Common::Hashtable data;
like I did in the above sample code.
PPS:
Also I changed"key"
toL"key". by passing a wide string literal in the first place, this saves the conversion from narrow string to wide string that would appear in your code.
PPPS:
Are you aware of demo_typeSupport inside the Client SDKs demo folder?
CPhotonLib::sendData() in the code of that demo demonstrates how to send various types of data and among other things it also puts various arrays into a Hashtable.
For questions like this having a look at that demo makes sense so that you can figure it out immediately by yourself and don't have to wait until you get an answer in the forum.5