…or am I missing something?
This code worked in 1.3.3, as I recall, for sending data to the server for storage in arrays, and subsequent retrieval. Now, I can’t get it to work in 1.5.2…
[B]public void storeAmfData(IClient client, RequestFunction function, AMFDataList params) {
// Send a string from the client, and store it in an object...
String testName_str = getParamString(params, PARAM1);
getLogger().info("storeAmfData called with name: " + testName_str);
// Create an array to hold a group of AMFDataObj's
AMFDataArray testInfo_array = new AMFDataArray();
// Create a test AMFDataObj to hold data...
AMFDataObj test_obj = new AMFDataObj();
test_obj.put("testName_str", new AMFDataItem(testName_str));
test_obj.put("testHobby_str", new AMFDataItem("no Hobby"));
test_obj.put("testID_int", new AMFDataItem(14));
// Does the loginSO already exist?
boolean testSoExists_bool = client.getAppInstance().getSharedObjects(true).exists("TestDataStorage/testDataStorage");
// SO handle...
SharedObject user_so;
// Get the SO, if it exists...
if(testSoExists_bool) {
user_so = new SharedObject("TestDataStorage/testDataStorage", true,
client.getAppInstance().getSharedObjects(true).getStorageDir());
getLogger().info("SO obtained from storeAmfData()");
} else {
// ...and register it if it doesn't yet exist.
user_so = new SharedObject("TestDataStorage/testDataStorage", true,
client.getAppInstance().getSharedObjects(true).getStorageDir());
client.getAppInstance().getSharedObjects(true).put("TestDataStorage/testDataStorage", user_so);
getLogger().info("New SO created from storeAmfData()");
}
if(user_so.containsProperty("testInfo_array")) {
testInfo_array = (AMFDataArray)user_so.getProperty("testInfo_array");
getLogger().info("SO contains... testInfo_array");
}
getLogger().info("DEBUG::testInfo_array.size(): " + testInfo_array.size());
testInfo_array.add(test_obj);
getLogger().info("DEBUG::testInfo_array.size(): " + testInfo_array.size());
getLogger().info("DEBUG::*** ARRAY...");
for(int i = 0; i < testInfo_array.size(); i++){
getLogger().info("DEBUG::index: " + i);
getLogger().info("DEBUG::testName_str: " + testInfo_array.getObject(i).getString("testName_str"));
getLogger().info("DEBUG::testHobby_str: " + testInfo_array.getObject(i).getString("testHobby_str"));
getLogger().info("DEBUG::testID_int: " + testInfo_array.getObject(i).getInt("testID_int"));
}
//user_so.lock();
synchronized(user_so) {
user_so.setProperty("testInfo_array", testInfo_array);
user_so.flush();
}
//user_so.unlock();
user_so = null;
sendResult(client, params, "Hello. Stored data.");
}[/B]
I used synchronized() for 1.3.3 and lock() for 1.5.2
First call of the method works as expected. Second call results in this error…
ERROR server comment - invoke(storeAmfData): java.lang.ClassCastException: com.wowza.wms.amf.AMFDataMixedArray cannot be cast to com.wowza.wms.amf.AMFDataArray: accWowzaDataExample.AccDataExample.storeAmfData(AccDataExample.java:84)
java.lang.ClassCastException: com.wowza.wms.amf.AMFDataMixedArray cannot be cast to com.wowza.wms.amf.AMFDataArray
So, it seems to be storing my AMFDataArray as an AMFDataMixedArray, which I don’t want, because the AMFDataMixedArray doesn’t have the methods I need.
I also tried AMFDataList, instead of AMFDataArray, but that didn’t work with either 1.3.3 or 1.5.2, even though it seems as though it should have.
Suggestions? My app depends on being able to store, retrieve and delete clients’ data and info, and the arrays of objects is the handiest way to do that.