Red5 configuration details)

Source: Internet
Author: User
Configuration Red5 Explanation (transfer) Red5 Set all applications Program All placed in Red5 The "webapps" directory under the root directory. You need to add the corresponding directory under the webapps directory for the created program. There should be a directory named "WEB-INF" in your app directory to store your app's configuration files. There is a template in the "DOC/templates/MyApp" directory to help you complete the initial work of creating a program.
Red5 At startup, all program files in the "webapps" directory are searched for configuration files under the "WEB-INF" directory to complete the configuration.
The most important configuration file is "Web. xml ". This file contains the following parameters:
Globalscope: Specify the global scope
<Context-param>
<Param-Name> globalscope </param-Name>
<Param-value> default </param-value>
</Context-param>
Contextconfiglocation: Specifies the location of the handler file. These configuration files describe the processing method called after the client's addition/exit action is triggered. You can use wildcards to describe multiple files during the description:
<Context-param>
<Param-Name> contextconfiglocation </param-Name>
/WEB-INF/ Red5 -*. Xml </param-value>
</Context-param>
Locatorfactoryselector: the root context of the program, usually" Red5 . Xml"
<Context-param>
<Param-Name> locatorfactoryselector </param-Name>
<Param-value> Red5 . Xml </param-value>
</Context-param>
Parentcontextkey: parent context, usually "Default. Context"
<Context-param>
<Param-Name> parentcontextkey </param-Name>
<Param-value> default. Context </param-value>
</Context-param>
Log4jconfiglocation: Location of the log configuration file
<Context-param>
<Param-Name> log4jconfiglocation </param-Name>
<Param-value>/WEB-INF/log4j. properties </param-value>
</Context-param>
Webapprootkey: globally unique name of the program
<Context-param>
<Param-Name> webapprootkey </param-Name>
<Param-value>/MyApp </param-value>
</Context-param>
Each handler configuration file requires at least three beans.
Context: used to film a path to a specific scope, search service, and handler. It has a reserved name "Web. context ". Its default class is Org. Red5 . Server. Context
<Bean id = "Web. Context" class = "org. Red5 . Server. Context"
Autowire = "bytype"/>
No application should have only one context, but the same context can be shared by multiple scopes.
Scope: each application has at least one scope to connect handler to the context and server. You can create a tree in the scope of action. Each client connects to a node in the tree, and the shared object exists in the scope of action. It can be regarded as a chat room or program instance. The default function scope is usually web. Scope, but this name can be obtained at will.
Bean has the following attributes:
Server: Global server" Red5 . Server "related.
Parent: Specifies the parent range of the current range, usually "Global. Scope"
Context: the context of the server in the current range. It is generally specified as "Web. context"
Handler: Handler corresponding to the current range
Contextpath: the path used to connect to the current range
Virtualhosts: A list of host names or IP addresses used to describe the locations of virtual hosts. list items are separated by commas.
<Bean id = "Web. Scope" class = "org. Red5 . Server. webscope"
Init-method = "register">
<Property name = "server" ref =" Red5 . Server "/>
<Property name = "parent" ref = "Global. Scope"/>
<Property name = "context" ref = "Web. Context"/>
<Property name = "handler" ref = "Web. Handler"/>
<Property name = "contextpath" value = "/MyApp"/>
<Property name = "virtualhosts" value = "localhost, 127.0.0.1"/>
</Bean>
To facilitate application configuration, you can put "contextpath" and "virtualhosts" in another separate property file, which is represented by variables, add a special bean to specify the location of the property file.
<Bean id = "placeholderconfig" class = "org. springframework. Beans. Factory. config. propertyplaceholderconfigurer">
<Property name = "location" value = "/WEB-INF/ Red5 -Web. properties "/>
</Bean>
Assume that in the attribute File Red5 -Web. properties contains the following data:
Webapp. contextpath =/MyApp
Webapp. virtualhosts = localhost, 127.0.0.1
Then, the "contextpath" and "virtualhosts" attributes of the bean above can be used to specify the value
<Property name = "contextpath" value = "http://www.ruyiblog.com/?#webapp.contextpath}"/>
<Property name = "virtualhosts" value = "http://www.ruyiblog.com/?#webapp.virtualhosts}"/>
For "contextpath", it can be considered as a root scope. You can add other paths at will behind the configured "contextpath" path. Clients connected to these paths will dynamically create additional scopes, which use the same handler, however, it has its own attributes, shared objects, and activity streams.
Handler: each context requires a handler to respond to the actions when the user connects and leaves the scope of action. Handler implements many methods that can be called for specific purposes. This handler must implement "org. Red5 . Server. API. iscopehandler "interface, of course, other interfaces should be implemented for access to shared objects and streams.
At. Red5 . Server. Adapter. applicationadapter "can be used as an example of a base class. You should also refer to the document for more details.
Handler of a specific range can be specified as follows:
<Bean id = "Web. Handler"
Class = "The. Path. to. My. Application"
Singleton = "true"/>
The "ID" attribute is specified in the scope defined above.
If you do not need any server-side logic processing, you can use Red5 Handler provided by default
<Bean id = "Web. Handler"
Class = "org. Red5 . Server. Adapter. applicationadapter"
Singleton = "true"/>
Handler example
Package the. Path. to. My;
Import Org. Red5 . Server. Adapter. applicationadapter;
Public class application extends applicationadapter {
Public double add (double A, double B ){
Return A + B;
}
}
If the above configuration is used, the following method is used when the client calls
NC = new netconnection ();
NC. Connect ("rtmp: // localhost/MyApp ");
NC. onresult = function (OBJ ){
Trace ("the result is" + OBJ );
}
NC. Call ("add", NC, 1, 2 );
Returns the output due to the error:
The result is 3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.