Wowza Community

Object persistance

Hello all,

I used code of the textchat example which I rewrote for my own use.

What this does now:

It makes an sharedObject on connect of an client (if the so does not exist yet).

On update of the So all the clients which are connected recieve the updated So with no problem.

Now I’d like to make the sharedObjects persistant.

This is where i’m stuck now…

If I make the shared object persistant with the appInstance.getSharedObjects(true);

Then suddenly the connected clients doesnot recieve any updates anymore.

I read a lot posts about persistance but im still missing a piece of the puzzle.

My final goal is that i can store a few presets on the server and maintain and recall them anytime.

My So’s stores x and y coordinates, url’s, rotation information ect…

Can somebody shine his light on my code?

Thx in advance,


package tv.meuk.server;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.wowza.wms.amf.AMFDataItem;
import com.wowza.wms.amf.AMFDataList;
import com.wowza.wms.amf.AMFDataObj;
import com.wowza.wms.application.IApplicationInstance;
import com.wowza.wms.client.IClient;
import com.wowza.wms.module.ModuleBase;
import com.wowza.wms.request.RequestFunction;
import com.wowza.wms.sharedobject.ISharedObject;
import com.wowza.wms.sharedobject.ISharedObjects;
import com.wowza.wms.sharedobject.SharedObject;
public class Connector extends ModuleBase {
	private Map<String, ISharedObject> sharedObjectList = new HashMap<String, ISharedObject>();
	private ISharedObject getSharedObject(String soName, IApplicationInstance appInstance)
		ISharedObject ret = null;
			// get the shared object if it already exists
			ret = sharedObjectList.get(soName);
			if (ret == null)
				// create a new shared object if it does not exist and initialize it
				getLogger().info("Connector.getSharedObject: create shared object: "+soName);
				// Original code befor persistance attempt
				//ISharedObjects sharedObjects = appInstance.getSharedObjects();
				//ret = new SharedObject(soName);
				// Modyfied code as an attempt to make the So's persistant which does not work properly
				ISharedObjects sharedObjects = appInstance.getSharedObjects(true);
				ret = new SharedObject(soName,true, sharedObjects.getStorageDir());
				sharedObjects.put(soName, ret);
				sharedObjectList.put(soName, ret);
				ret.setProperty("lastChatId", new AMFDataItem("0"));
				//another attempt to set persistance
		return ret;
	public void initSharedObject(IClient client, RequestFunction function, AMFDataList params)
		// make sure we create the shared object server side so we can initialize it properly
		String soName = params.getString(PARAM1);
		getLogger().info("Connector.initSharedObject: init shared object: "+soName);
		ISharedObject connector_so = getSharedObject(soName, client.getAppInstance());
		//another attempt to set persistance
		getLogger().info("Connector.initSharedObject: getStorageName: "+connector_so.getStorageDir());
		sendResult(client, params, soName);
	// call from client to add message
	public void addMessage(IClient client, RequestFunction function, AMFDataList params) 
		String soName = params.getString(PARAM1);
		AMFDataObj recievedObject = params.getObject(PARAM2);
		// get the shared object
		ISharedObject connector_so = getSharedObject(soName, client.getAppInstance());
		//another attempt to set persistance
			String propName = "recievedObject";			
			getLogger().info("Connector.addMessage: message id: "+propName);
			connector_so.setProperty(propName, recievedObject);
			getLogger().info("Connector.addMessage: recievedObject: "+recievedObject);
			//connector_so.setProperty("whateverToAddHere", new AMFDataItem("whateverValue"));
	public void onAppStop(IApplicationInstance appInstance) 
			Iterator<String> iter = sharedObjectList.keySet().iterator();
				String soName =;
				getLogger().info("Connector.onAppStop: release shared object: "+soName);
				ISharedObject toRelease_so = sharedObjectList.get(soName);
	public void doSomething(IClient client, RequestFunction function,
			AMFDataList params) {
		sendResult(client, params, "Hello Wowza");
	public void onAppStart(IApplicationInstance appInstance)
		getLogger().info("onAppStart: "+appInstance.getApplication().getName()+"/"+appInstance.getName());
//	public void onAppStop(IApplicationInstance appInstance)
//	{
//		getLogger().info("onAppStop: "+appInstance.getApplication().getName()+"/"+appInstance.getName());
//	}
	public void onConnect(IClient client, RequestFunction function,
			AMFDataList params) {
		getLogger().info("onConnect: " + client.getClientId());
	public void onConnectAccept(IClient client) {
		getLogger().info("onConnectAccept: " + client.getClientId());
	public void onConnectReject(IClient client) {
		getLogger().info("onConnectReject: " + client.getClientId());
	public void onDisconnect(IClient client) {
		getLogger().info("onDisconnect: " + client.getClientId());
	public void onCall(String handlerName, IClient client,
			RequestFunction function, AMFDataList params) {
		getLogger().info("onCall: " + handlerName);

You need to set the persist flag on the client side as well. See the as3 docs for SharedObject.getRemote.

Thank you so much!

I changed one Boolean on the client side, and now it works…

I wish everything in live was so simple.


.... = SharedObject.getRemote("someObject", my_nc.uri,);


.... = SharedObject.getRemote("someObject", my_nc.uri,[B][SIZE=4] true[/SIZE][/B]);