
package sampleSharedObjectListener;

import org.red5.server.adapter.*;
import org.red5.server.api.so.*;
import org.red5.server.api.IScope;
import java.util.List;

public class Application extends ApplicationAdapter  {

	public class SampleSharedObjectListener implements ISharedObjectListener {
		public void onSharedObjectUpdate(ISharedObject so, String key, Object value) {
			// The attribute <key> of the shared object <so>
			// was changed to <value>.
			System.out.println("SO changes detected!");
		}
	
		public void onSharedObjectDelete(ISharedObject so, String key) {
			// The attribute <key> of the shared object <so> was deleted.
		}
	
		public void onSharedObjectSend(ISharedObject so, String method, List params) {
			// The handler <method> of the shared object <so> was called
			// with the parameters <params>.
		}
	
		public void onSharedObjectConnect(ISharedObject so) {
			// TODO Auto-generated method stub			
		}
	
		public void onSharedObjectSend(ISharedObject arg0, String arg1, Object[] arg2) {
			// TODO Auto-generated method stub	
		}
	
	}

	public boolean appStart(IScope scope) {
		// Original code:
		ISharedObject so = getSharedObject(scope, "sampleSO");
		so.addSharedObjectListener(new SampleSharedObjectListener());
		/*
		Eclipse says:
		-The method getSharedObject(String) in the type ApplicationAdapter is not applicable for the arguments (IScope, String)	Application.java
		-The method addSharedObjectListener(Application.SampleSharedObjectListener) is undefined for the type ISharedObject	Application.java		
		*/
		

		// My code (doesn't work either):
		// ISharedObject so = getSharedObject("sampleSO");
		// so.addEventListener(new SampleSharedObjectListener());

		return true;
	}
}
