package { import com.adobe.rtc.events.SessionEvent; import com.adobe.rtc.session.IConnectSession; import com.adobe.rtc.sharedModel.SharedProperty; public class SharedPropertyAuto extends SharedProperty { public function SharedPropertyAuto() { super(); } /** * connectSession overriden, to add listener * @return Boolean */ private var __connectSession:IConnectSession; public override function set connectSession(p_session:IConnectSession):void{ __connectSession = p_session; __connectSession.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE,onConnectSessionSync); } public override function get connectSession():IConnectSession{ return __connectSession; } /** * autoSubscribe determines, whether to automatically subscribe property, when connect session is synchronized * @return Boolean */ private var _autoSubscribe:Boolean = true; public function set autoSubscribe(value:Boolean):void{ _autoSubscribe = value; } public function get autoSubscribe():Boolean{ return _autoSubscribe; } private function onConnectSessionSync(event:SessionEvent):void{ if(__connectSession.isSynchronized){ if(autoSubscribe){ subscribe(); } } } } }