Red5 Introduction and basic knowledge

Source: Internet
Author: User
Tags event listener
Brief introduction

Red5 's main function is similar to Macromedia's FMS, which provides a Java based Open-source streaming media server for streaming media services based on Flash. It is written by the Java language and uses rtmp as a streaming media transport protocol, which is fully compatible with FMS. It has streaming flv, MP3 files, real-time recording client streams for FLV files, shared objects, real-time video playback, remoting and other functions. After replacing the FMS with RED5, the client does not have to change to function properly.

Provide Red5-RELATED links:

Official website: http://www.red5.org/

Download Address: http://www.red5.org/downloads/

Related example: Http://trac.red5.org/wiki/Examples

Related documents: Http://trac.red5.org/wiki/Documentation

Run the deployment instance currently red5 the highest version is 1.0RC1, I use the 0.9.1Final version, Red5 specific use of the example online there are many, in this I recommend a Web site, the author made a Red5 introductory video, very suitable for beginners to get started: http://plter.com/ archives/524 Note: If the Red5 has not yet started, it is not recommended to look at the later content. The Applicationadapter class Applicationadapter class is a subclass of Multithreadedapplicationadapter. Applicationadapter the message that a method call is made using a single-threaded approach, so its performance is not as good as multithreadedapplicationadapter. The Multithreadedapplicationadapter class is the base class for the Red5 application. It provides a way to manipulate sharedobjects and streams, as well as a list of connections and services, an application-basic iscope. Generally, application development will inherit the Applicationadapter class. In development, we often contact the following methods, which are implemented through Multithreadedapplicationadapter: Java code//RED5 automatically executes this method when the application starts public boolean AppStart ( Iscope arg0)//red5 automatic execution of this method when the application is stopped Java code public void Appstop (Iscope arg0)

Methods that are run automatically when a flex client connects to a project Java code public boolean appconnect (Iconnection arg0, object[] arg1)

Methods that are triggered when flex clients disconnect from the server Java code public void Appdisconnect (Iconnection arg0)

Flex clients run when connected to the server, similar to Java code public boolean appjoin (IClient arg0, iscope arg1) compared to AppConnect

Flex client runs when disconnected from server, similar to appdisconnect Java code public void Appleave (IClient arg0, Iscope arg1)

Red5 Key API

RED5 provides a number of interfaces for developers to develop two times:

iconnection: Connection object. Each connection has an associated client and domain. The connection may be persistent, polling, or transient. The purpose of this interface is to provide a basic generic method for different subclasses such as rtmpconnection,remotingconnection,ajaxconnection, httpconnection, etc. It provides a getclient () method for obtaining customer service-side objects.

iscope : Each RED5 application has at least one domain that is used to build the processor, the scene, and the connections between servers. Domains can form a tree structure, and all clients can act as objects (such as streams and data) within their nodes ' shared domains. All customer service terminals (client) are connected to the domain through a connection (connection). For a single domain, each connection corresponds to a customer service side, each customer service side corresponding to an ID, simple application, operation on an ID and a connection.

iservicecapableconnection : Get a valid connection. The code gets the connection instance first, then determines whether it is a valid connection and forces type conversion, and then the client-side function is fetched.

iclient : The client object represents a single client. A client can establish a connection with a different domain under the same host. The client object is similar to the HTTP session. You can use the Iclientregistry.newclient (object[]) method to create a IClient object.

Applicationadapter: Applicationadapter is the iscope of application level. To handle the flow process, you need to implement the corresponding processing method in the Istreamawarescopehandler interface. Applicationadapter also provides an effective event-handling mechanism for intercepting streams, confirming users, and so on. At the same time, the method introduced in its subclass can be fetched through netconnection in the client. In Aodbe FMS, the client object must be maintained on the server side, which, in contrast, provides a more convenient and efficient way to Red5 your remote request.       Simple Example "Flex Client connection Red5 Server"   ActionScript provides a netconnection connection to a server that can be invoked after a connection to the Red5 method. You can also specify a client object for Red5 calls. The following code is a connection to a project that you created in Red5, and listens for connectivity through events: Java code   //Create Netconnection instance    var netconn: Netconnection = new netconnection ();  //Specifies the rtmp address and passes a parameter value "Hello" to the server    Netconn.connect ("Rtmp://localhost/chatroom", "Hello");  //Add Netstatus Event Listener Connection    Netconn.addeventlistener (Netstatusevent.net_status,function connstatus (e:netstatusevent):void{                             switch (e.info.code) {                                 //Connection Success                                 case  " NetConnection.Connect.Success ":                                     l_connStatus.text =  "connected successfully";                                     break;                                 //Server Disconnected                                 case  "NetConnection.Connect.Closed":                                     l_connstatus.text  =  "Disconnected";                                     break;                                //can be connected, but denied access to the                                 case  "NetConnection.Connect.Failed":                                     l_connStatus.text =  "Connection denied";                                     break;                                default:                                     break;                            }                        &NBSP});   the code into a flex event that connects Red5 when the event is triggered.     "Client Call server Method" client calls server methods are very common, and sometimes you take the initiative to get video resources to the server or send message information to the server. Netconnection Call (command:string,responder:responder,... arguments) is used to invoke the server method, command   Specify the method name of the server being invoked Responder an optional object that handles the return value of the server, which is the form of a callback, so you need to instantiate the responder object, and then create a method in the object body to get the server return value, or null if there is no return value. Arguments optional parameters that are passed to the method   The following code describes how to send a message to the server when the method specified in the   command  parameter is executed on the remote application server:

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.