Exemple #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);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Returns security handlers for this shared object or null if none are found.
        /// </summary>
        /// <returns>Collection of ISharedObjectSecurity objects.</returns>
        private IEnumerator GetSecurityHandlers()
        {
            ISharedObjectSecurityService security = ScopeUtils.GetScopeService(this.Parent, typeof(ISharedObjectSecurityService)) as ISharedObjectSecurityService;

            if (security == null)
            {
                return(null);
            }
            return(security.GetSharedObjectSecurity());
        }
Exemple #3
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);
        }