Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        /// <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));
        }
Exemplo n.º 4
0
        /// <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>
        /// <returns>Shared object instance with the specifed name.</returns>
		public ISharedObject GetSharedObject(IScope scope, string name)
		{
            ISharedObjectService service = (ISharedObjectService)ScopeUtils.GetScopeService(scope, typeof(ISharedObjectService));
			return service.GetSharedObject(scope, name);
		}