FluorineFx.NET

The Scope model

In a real-time messaging enabled application resources are managed in a tree. Each node of a tree is called a scope. A Scope is a statefull object shared between a group of clients connected to the same context path. If the scope is a leaf node, it is called a BasicScope and if the scope contains child scopes, it is called a Scope. There are two pre-defined BasicScopes: SharedObject Scope and BroadcastStream Scope.

Each Application has its own Scope hierarchy and the root scope is the WebScope. There's also a global scope that is the parent of WebScope. Each scope has a name. The GlobalScope is named "default". The WebScope is named per Application context root. Other Scopes are named per path name. The SharedObject Scope is named per SharedObject's name. The BroadcastStream Scope is named per Stream's name.

The GlobalScope provides resource and service sharing across Applications.

Except GlobalScope and BasicScopes, all Scopes can be connected by a client. A Scope object might be created as a result of a connection request from a client. For example, a client could issue a request to connect to application/room0 when the room0 scope does not exist. After the establishment of the connection, room0 is created. If the url contains many intermediate scopes, all these scopes will be created. For example, application/lobby0/room0 is requested and neither lobby0 or room0 exist, lobby0 and room0 will be created accordingly. Then the connection is tied to room0 scope.

 

A typical scope hierarchy could be like this:

GlobalScope(default) --> WebScope(application) --> Scope(room0) --> BroadcastStream(live0), SharedObject(so1)
                                               --> Scope(room1) --> SharedObject(so0)

In the previous sample a nc.connect("rtmp://localhost:1935/application") call will connect the client to the WebScope.

The Service Hierarchy

The IServiceProvider interface defines a mechanism for retrieving a service object. Each Scope object is a service provider.

Services are managed in a tree (service hierarchy). A service hierarchy is made up of several ServiceContainers. A ServiceContainer is used to store an instance of a class that provides a service against its type. You can request a service instance by passing its type.

Service containers are usually bound to a parent. This means that when a service is requested and it is not found in the container, the container asks its parent and so on. (Service containers have no concept of children, only of parents). Each Scope holds a service container having as parent the parent Scope's service container.

At the GlobalScope level you have services such as IStreamableFileFactory, IBWControlService.
At the WebScope level you have services such as IStreamFilenameGenerator, ISharedObjectSecurityService etc.