public void Register() { lock (base.SyncRoot) { if (!this._isRegistered) { IStreamFilenameGenerator generator = ObjectFactory.CreateInstance(this._appConfig.StreamFilenameGenerator.Type) as IStreamFilenameGenerator; base.AddService(typeof(IStreamFilenameGenerator), generator, false); generator.Start(this._appConfig.StreamFilenameGenerator); ISharedObjectService service = ObjectFactory.CreateInstance(this._appConfig.SharedObjectServiceConfiguration.Type) as ISharedObjectService; base.AddService(typeof(ISharedObjectService), service, false); service.Start(this._appConfig.SharedObjectServiceConfiguration); IProviderService service2 = ObjectFactory.CreateInstance(this._appConfig.ProviderServiceConfiguration.Type) as IProviderService; base.AddService(typeof(IProviderService), service2, false); service2.Start(this._appConfig.ProviderServiceConfiguration); IConsumerService service3 = ObjectFactory.CreateInstance(this._appConfig.ConsumerServiceConfiguration.Type) as IConsumerService; base.AddService(typeof(IConsumerService), service3, false); service3.Start(this._appConfig.ConsumerServiceConfiguration); IStreamService service4 = ObjectFactory.CreateInstance(this._appConfig.StreamService.Type) as IStreamService; base.AddService(typeof(IStreamService), service4, false); service4.Start(this._appConfig.StreamService); if (this._appConfig.SharedObjectSecurityService.Type != null) { ISharedObjectSecurityService service5 = ObjectFactory.CreateInstance(this._appConfig.SharedObjectSecurityService.Type) as ISharedObjectSecurityService; base.AddService(typeof(ISharedObjectSecurityService), service5, false); service5.Start(this._appConfig.SharedObjectSecurityService); } base.Init(); base._keepOnDisconnect = true; this._isRegistered = true; } } }
protected override void OnSharedObject(RtmpConnection connection, RtmpChannel channel, RtmpHeader header, SharedObjectMessage message) { ISharedObject sharedObject = null; string name = message.Name; IScope scope = connection.Scope; bool isPersistent = message.IsPersistent; if (scope == null) { SharedObjectMessage message2; if (connection.ObjectEncoding == ObjectEncoding.AMF0) { message2 = new SharedObjectMessage(name, 0, isPersistent); } else { message2 = new FlexSharedObjectMessage(name, 0, isPersistent); } message2.AddEvent(new SharedObjectEvent(SharedObjectEventType.CLIENT_STATUS, "SharedObject.NoObjectFound", "error")); connection.GetChannel(3).Write(message2); } else { ISharedObjectService scopeService = ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)) as ISharedObjectService; if (!scopeService.HasSharedObject(scope, name)) { ISharedObjectSecurityService service2 = ScopeUtils.GetScopeService(scope, typeof(ISharedObjectSecurityService)) as ISharedObjectSecurityService; if (service2 != null) { IEnumerator sharedObjectSecurity = service2.GetSharedObjectSecurity(); while (sharedObjectSecurity.MoveNext()) { ISharedObjectSecurity current = sharedObjectSecurity.Current as ISharedObjectSecurity; if (!current.IsCreationAllowed(scope, name, isPersistent)) { SendSOCreationFailed(connection, name, isPersistent); return; } } } if (!scopeService.CreateSharedObject(scope, name, isPersistent)) { SendSOCreationFailed(connection, name, isPersistent); return; } } sharedObject = scopeService.GetSharedObject(scope, name); if (sharedObject.IsPersistentObject != isPersistent) { log.Debug(string.Format("Shared object '{0}' persistence mismatch", name)); SendSOPersistenceMismatch(connection, name, isPersistent); } else { sharedObject.DispatchEvent(message); } } }
protected override void OnSharedObject(RtmpConnection connection, RtmpChannel channel, RtmpHeader header, SharedObjectMessage message) { ISharedObject so = null; string name = message.Name; IScope scope = connection.Scope; bool persistent = message.IsPersistent; if (scope == null) { // The scope already has been deleted. SendSOCreationFailed(connection, name, persistent); return; } ISharedObjectService sharedObjectService = ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)) as ISharedObjectService; if (!sharedObjectService.HasSharedObject(scope, name)) { ISharedObjectSecurityService securityService = ScopeUtils.GetScopeService(scope, typeof(ISharedObjectSecurityService)) as ISharedObjectSecurityService; if (securityService != null) { // Check handlers to see if creation is allowed IEnumerator enumerator = securityService.GetSharedObjectSecurity(); while (enumerator.MoveNext()) { ISharedObjectSecurity handler = enumerator.Current as ISharedObjectSecurity; if (!handler.IsCreationAllowed(scope, name, persistent)) { SendSOCreationFailed(connection, name, persistent); return; } } } if (!sharedObjectService.CreateSharedObject(scope, name, persistent)) { SendSOCreationFailed(connection, name, persistent); return; } } so = sharedObjectService.GetSharedObject(scope, name); if (so.IsPersistentObject != persistent) { log.Debug(string.Format("Shared object '{0}' persistence mismatch", name)); SendSOPersistenceMismatch(connection, name, persistent); return; } so.DispatchEvent(message); }
/// <summary> /// <para> /// Deletes persistent shared objects specified by name and clears all /// properties from active shared objects (persistent and nonpersistent). The /// name parameter specifies the name of a shared object, which can include a /// slash (/) as a delimiter between directories in the path. The last /// element in the path can contain wildcard patterns (for example, a /// question mark [?] and an asterisk [*]) or a shared object name. The /// ClearSharedObjects() method traverses the shared object hierarchy along /// the specified path and clears all the shared objects. Specifying a slash /// (/) clears all the shared objects associated with an application /// instance. /// </para> /// The following values are possible for the soPath parameter: /// <list type="table"> /// <listheader> /// <term>soPath parameter</term> /// <description>action</description> /// </listheader> /// <item><term></term> /// <description>clears all local and persistent shared objects associated with the instance</description></item> /// <item><term>/foo/bar</term> /// <description>clears the shared object /foo/bar; if bar is a directory name, no shared objects are deleted</description></item> /// <item><term>/foo/bar/*</term> /// <description>clears all shared objects stored under the instance directory</description></item> /// <item><term>/foo/bar.</term> /// <description>the bar directory is also deleted if no persistent shared objects are in use within this namespace</description></item> /// <item><term>/foo/bar/XX??</term> /// <description>clears all shared objects that begin with XX, followed by any two characters</description></item> /// </list> /// If a directory name matches this specification, all the shared objects within this directory are cleared. /// /// If you call the ClearSharedObjects() method and the specified path /// matches a shared object that is currently active, all its properties are /// deleted, and a "clear" event is sent to all subscribers of the shared /// object. If it is a persistent shared object, the persistent store is also cleared. /// </summary> /// <param name="scope">Scope that shared object belongs to.</param> /// <param name="name">Name of SharedObject.</param> /// <returns>true if successful, false otherwise.</returns> public bool ClearSharedObjects(IScope scope, string name) { ISharedObjectService service = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return(service.ClearSharedObjects(scope, name)); }
/// <summary> /// Returns shared object from given scope by name. /// </summary> /// <param name="scope">Scope that shared object belongs to.</param> /// <param name="name">Name of SharedObject.</param> /// <param name="persistent">Whether SharedObject instance should be persistent or not.</param> /// <returns>Shared object instance with the specifed name.</returns> public ISharedObject GetSharedObject(IScope scope, string name, bool persistent) { ISharedObjectService service = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return(service.GetSharedObject(scope, name, persistent)); }
/// <summary> /// Returns a collection of available SharedObject names. /// </summary> /// <param name="scope">Scope that SharedObjects belong to.</param> /// <returns>Collection of available SharedObject names.</returns> public ICollection GetSharedObjectNames(IScope scope) { ISharedObjectService service = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return(service.GetSharedObjectNames(scope)); }
/// <summary> /// Checks whether there is a SharedObject with given scope and name. /// </summary> /// <param name="scope">Scope that shared object belongs to.</param> /// <param name="name">Name of SharedObject.</param> /// <returns>true if SharedObject exists, false otherwise.</returns> public bool HasSharedObject(IScope scope, string name) { ISharedObjectService service = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return service.HasSharedObject(scope, name); }
public ISharedObject GetSharedObject(IScope scope, string name) { ISharedObjectService scopeService = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService)); return(scopeService.GetSharedObject(scope, name)); }