SlideShare uma empresa Scribd logo
1 de 17
What is red5
• An Open Source Flash Media Server
• Built on Java (Mina & Spring)
• Uses RTMP (Real Time Messaging Protocol)
• Streaming Audio/Video (FLV and MP3)
• Recording Client Streams (FLV only)
• Shared Objects
• Live Stream Publishing
• Remoting (AMF)
• Multi-User Environments
What you need to get started
• Eclipse 3.1
• J2EE
• Flash IDE/Flash Develop/Flex
• Red5 ( http://svn1.cvsdude.com/osflash/red5_ )
For more info on red5 release visit:
http://www.red5world.com/downloads
Building an application
Application Directory
red5
-webapps
-Application Name
-WEB-INF (contains configuration files & classes)
-src
-lib
-classes
web.xml
red5-web.xml
red5-web.properties
*Note: This structure will always be the same
Building an application cont…
A closer look at the WEB-INF directories
WEB-INF
- src (contains all .java, .js, .py, .rb, files used to build your app.)
- lib (contains all jar files required )
- classes (contains the compiled class files from the src directory)
web.xml (this is the main configuration file for your app)
globalScope
contextConfigLocation
locatorFactorySelector
parentContextKey
log4jConfigLocation
webAppRootKey
Building an application cont…
web.xml (view sample file)
globalScope
<context-param>
<param-name>globalScope</param-name>
<param-value>default</param-value>
</context-param>
contextConfigLocation
Specifies the name(s) of handler configuration files for this application.
Additionally, the handler configuration files specify the scope hierarchy for
these classes. The path name given here can contain wildcards to load multiple files:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/red5-*.xml</param-value>
</context-param>
locatorFactorySelector
References the configuration file of the root application context which usually is “red5.xml”::
<context-param>
<param-name>locatorFactorySelector</param-name>
<param-value>red5.xml</param-value>
</context-param>
Building an application cont…
web.xml (view sample file)
parentContextKey
Name of the parent context, this usually is “default.context”::
<context-param>
<param-name>parentContextKey</param-name>
<param-value>default.context</param-value>
</context-param>
log4jConfigLocation
Path to the configuration file for the logging subsystem::
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
webAppRootKey
Unique name for this application, should be the public name::
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>/myapp</param-value>
</context-param>
Building an application cont…
red5-web.xml (view sample file)
Handler configuration
Every handler configuration file must contain at least three beans:
1. Context (The context bean has the reserved name web.context and is used to
map paths to scopes, lookup services and handlers.)
By default this bean is specified as:
<bean id="web.context" class="org.red5.server.Context"
autowire="byType" />
Every application can only have one context. However this context can be
shared across multiple scopes.
2. Scopes
Every application needs at least one scope that links the handler to the context and the server.
The scopes can be used to build a tree where clients can connect to every node and share
objects inside this scope (like shared objects or live streams). You can see the scopes as rooms
or instances. The default scope usually has the name web.scope, but the name can be chosen
arbitrarily.
Building and application cont…
red5-web.xml (view sample file)
2. Scopes cont…
The bean has the following properties:
• server (This references the global server)
• red5.server. parent (References the parent for this scope and usually is global.scope.)
• context (The server context for this scope, use the web.context from above.)
• handler (The handler for this scope (see below))
• contextPath (The path to use when connecting to this scope.)
• virtualHosts (A comma separated list of hostnames or IP addresses this scope runs at.)
Sample definition:
<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>
Building an application cont…
red5-web.xml (view sample file)
3. Handlers
Every context needs a handler that implements the methods called when a client connects to
the scope, leaves it and that contains additional methods that can be called by the client.
Sample implementation:
org.red5.server.adapter.ApplicationAdapter
The bean for a scope handler is configured by:
<bean id="web.handler“ class="the.path.to.my.Application“ singleton="true" />
The id attribute is referenced by the scope definition above.
If you don't need any special server-side logic, you can use the default application handler
provided by Red5:
<bean id="web.handler“ class="org.red5.server.adapter.ApplicationAdapter“ singleton="true" />
Building an application cont…
red5-web.xml (view sample file)
3. Handlers cont…
Sample handler:
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;
}
}
You can call this method using the following ActionScript:
nc = new NetConnection();
nc.connect("rtmp://localhost/myapp");
nc.onResult = function(obj) {
trace("The result is " + obj);
}
nc.call("add", nc, 1, 2);
red5 and AS3
How to build a red5 applications in AS3 (using the oflaDemo)
( view .fla )
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Initialize Connection
//////////////////////////////////////////////////////////////////////////////////////////////////////
nc = new NetConnection();
nc.client = this;
nc.addEventListener(NetStatusEvent.NET_STATUS, onConnectHandler);
nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onConnectErrorHandler);
nc.connect("rtmp://localhost/oflaDemo");
remote_so = SharedObject.getRemote("chat"+roomNum, nc.uri, false);
remote_so.addEventListener(SyncEvent.SYNC, onSyncHandler);
remote_so.connect(nc);
At this point you call your shared object „remote_so‟ anywhere in your AS to build functions around it,
store data, retrieve date, etc..
red5 and AS3
How to build a red5 applications in AS3 (using the oflaDemo)
( view .fla )
Here’s an example of how we call our shared object:
function loginUser():void {
if (remote_so.data.userArray == undefined) {
userArray = new Array();
} else {
userArray=remote_so.data.userArray;
}
userArray.push({name:userName});
remote_so.setProperty("userArray", userArray);
remote_so.setProperty("chatText", chatInputWin.chatInput.text);
remote_so.setDirty("userArray");
}
Coding custom functions in red5
Let‟s take a look at how to code a custom java function in red5 that we
can call later in ActionScript.
*Note: We will be modifying the oflaDemo app (Application.java)
JAVA SIDE FIRST: add some code to onconnect and ondisconnect
inside...
public boolean appConnect(IConnection conn, Object[] params)
add...
conn.getClient().setAttribute("name",params[0]);
inside...
public void appDisconnect(IConnection conn)
add...
String name=(String)conn.getClient().getAttribute("name");
Iterator<IConnection> conns3 = appScope.getConnections();
while(conns3.hasNext()) {
try{ //to notify clients
IConnection conn1=conns3.next();
((IServiceCapableConnection)conn1).invoke("userClose",new Object[]{name},this);
}
catch(Exception e){}
}
Coding custom functions in red5
JAVA cont…
Now we add some imports:
import java.util.Iterator;
import org.red5.server.api.service.IServiceCapableConnection;
import org.red5.server.api.service.IPendingServiceCall;
import org.red5.server.api.service.IPendingServiceCallback;
Then we will add to our declaration:
class Application extends ApplicationAdapter implements IPendingServiceCallback {
Then we will need to add one method to our java:
public void resultReceived(IPendingServiceCall call) {}
Now we can compile it!
Coding custom functions in red5
JAVA cont…
Now we can call our new function/method in ActionScript ("userClose“)
function userClose(name:String):void{
//Do something
}
That’s all there is to it!
Resources
• http://www.red5world.com
• http://osflash.org/red5
• http://www.nabble.com/Red5-f16328.html
• http://www.springframework.org
• http://mina.apache.org
References:
Daniel Rossi – Red5 Documentation PDF
OSFlash Red5 Wiki
OsFlash Red5 Mailer List

Mais conteúdo relacionado

Mais procurados

Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solrlucenerevolution
 
Web Application Development using MVC Framework Kohana
Web Application Development using MVC Framework KohanaWeb Application Development using MVC Framework Kohana
Web Application Development using MVC Framework KohanaArafat Rahman
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleRaimonds Simanovskis
 
Apache Web Server Architecture Chaitanya Kulkarni
Apache Web Server Architecture Chaitanya KulkarniApache Web Server Architecture Chaitanya Kulkarni
Apache Web Server Architecture Chaitanya Kulkarniwebhostingguy
 
SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3Ben Abdallah Helmi
 
SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3Ben Abdallah Helmi
 
RESTful Web Development with CakePHP
RESTful Web Development with CakePHPRESTful Web Development with CakePHP
RESTful Web Development with CakePHPAndru Weir
 
Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Alessandro Pilotti
 
Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6DEEPAK KHETAWAT
 
CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011Alexander Klimetschek
 

Mais procurados (20)

CakePHP REST Plugin
CakePHP REST PluginCakePHP REST Plugin
CakePHP REST Plugin
 
Lect06 tomcat1
Lect06 tomcat1Lect06 tomcat1
Lect06 tomcat1
 
Make your gui shine with ajax solr
Make your gui shine with ajax solrMake your gui shine with ajax solr
Make your gui shine with ajax solr
 
Web Application Development using MVC Framework Kohana
Web Application Development using MVC Framework KohanaWeb Application Development using MVC Framework Kohana
Web Application Development using MVC Framework Kohana
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
Wizard of ORDS
Wizard of ORDSWizard of ORDS
Wizard of ORDS
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
 
New PHP Exploitation Techniques
New PHP Exploitation TechniquesNew PHP Exploitation Techniques
New PHP Exploitation Techniques
 
Psr 7 symfony-day
Psr 7 symfony-dayPsr 7 symfony-day
Psr 7 symfony-day
 
Apache Web Server Architecture Chaitanya Kulkarni
Apache Web Server Architecture Chaitanya KulkarniApache Web Server Architecture Chaitanya Kulkarni
Apache Web Server Architecture Chaitanya Kulkarni
 
Ajax
AjaxAjax
Ajax
 
Laravel intake 37 all days
Laravel intake 37 all daysLaravel intake 37 all days
Laravel intake 37 all days
 
SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3
 
SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3
 
Spring WebApplication development
Spring WebApplication developmentSpring WebApplication development
Spring WebApplication development
 
RESTful Web Development with CakePHP
RESTful Web Development with CakePHPRESTful Web Development with CakePHP
RESTful Web Development with CakePHP
 
Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1Building drupal web farms with IIS - part 1
Building drupal web farms with IIS - part 1
 
Slim Framework
Slim FrameworkSlim Framework
Slim Framework
 
Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6
 
CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011CQ5 QueryBuilder - .adaptTo(Berlin) 2011
CQ5 QueryBuilder - .adaptTo(Berlin) 2011
 

Destaque

соц-дем 05-06'11 (NashKiev.UA)
соц-дем 05-06'11 (NashKiev.UA)соц-дем 05-06'11 (NashKiev.UA)
соц-дем 05-06'11 (NashKiev.UA)NashKiev.UA
 
соц-дем_01-02'11 (NashKiev.UA) 01-02'11
соц-дем_01-02'11 (NashKiev.UA)  01-02'11соц-дем_01-02'11 (NashKiev.UA)  01-02'11
соц-дем_01-02'11 (NashKiev.UA) 01-02'11NashKiev.UA
 
PoPI: Glyph Designs for Collaborative Filtering on Interactive Tabletops
PoPI: Glyph Designs for Collaborative Filtering on Interactive TabletopsPoPI: Glyph Designs for Collaborative Filtering on Interactive Tabletops
PoPI: Glyph Designs for Collaborative Filtering on Interactive TabletopsSven Charleer
 
Results of questionnaire
Results of questionnaireResults of questionnaire
Results of questionnaireshumi26
 
соц-дем_02-03'11 (NashKiev.UA) 02-03'11
соц-дем_02-03'11 (NashKiev.UA) 02-03'11соц-дем_02-03'11 (NashKiev.UA) 02-03'11
соц-дем_02-03'11 (NashKiev.UA) 02-03'11NashKiev.UA
 
Тем, кто предлагает услуги и товары (НашКиев.UA)
Тем, кто предлагает услуги и товары (НашКиев.UA)Тем, кто предлагает услуги и товары (НашКиев.UA)
Тем, кто предлагает услуги и товары (НашКиев.UA)NashKiev.UA
 

Destaque (15)

соц-дем 05-06'11 (NashKiev.UA)
соц-дем 05-06'11 (NashKiev.UA)соц-дем 05-06'11 (NashKiev.UA)
соц-дем 05-06'11 (NashKiev.UA)
 
Week6
Week6Week6
Week6
 
pp39-44 HEJoct16
pp39-44 HEJoct16pp39-44 HEJoct16
pp39-44 HEJoct16
 
соц-дем_01-02'11 (NashKiev.UA) 01-02'11
соц-дем_01-02'11 (NashKiev.UA)  01-02'11соц-дем_01-02'11 (NashKiev.UA)  01-02'11
соц-дем_01-02'11 (NashKiev.UA) 01-02'11
 
PoPI: Glyph Designs for Collaborative Filtering on Interactive Tabletops
PoPI: Glyph Designs for Collaborative Filtering on Interactive TabletopsPoPI: Glyph Designs for Collaborative Filtering on Interactive Tabletops
PoPI: Glyph Designs for Collaborative Filtering on Interactive Tabletops
 
Week15
Week15Week15
Week15
 
PENO3
PENO3PENO3
PENO3
 
Medical dressings - Asia
Medical dressings - AsiaMedical dressings - Asia
Medical dressings - Asia
 
Safety glass - Asia
Safety glass - AsiaSafety glass - Asia
Safety glass - Asia
 
Results of questionnaire
Results of questionnaireResults of questionnaire
Results of questionnaire
 
соц-дем_02-03'11 (NashKiev.UA) 02-03'11
соц-дем_02-03'11 (NashKiev.UA) 02-03'11соц-дем_02-03'11 (NashKiev.UA) 02-03'11
соц-дем_02-03'11 (NashKiev.UA) 02-03'11
 
LARA.emo #mume13
LARA.emo #mume13LARA.emo #mume13
LARA.emo #mume13
 
Potassic fertilizers - Australia, Africa and Americas
Potassic fertilizers - Australia, Africa and AmericasPotassic fertilizers - Australia, Africa and Americas
Potassic fertilizers - Australia, Africa and Americas
 
P&O3 session 1
P&O3 session 1P&O3 session 1
P&O3 session 1
 
Тем, кто предлагает услуги и товары (НашКиев.UA)
Тем, кто предлагает услуги и товары (НашКиев.UA)Тем, кто предлагает услуги и товары (НашКиев.UA)
Тем, кто предлагает услуги и товары (НашКиев.UA)
 

Semelhante a Red5workshop 090619073420-phpapp02

Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Racksickill
 
Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails BasicsAmit Solanki
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentationToufiq Mahmud
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.pptWalaSidhom1
 
Language Resource Processing Configuration and Run
Language Resource Processing Configuration and RunLanguage Resource Processing Configuration and Run
Language Resource Processing Configuration and Runmario_munoz
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platformNelson Kopliku
 
Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Charlin Agramonte
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperVinay Kumar
 
Rails
RailsRails
RailsSHC
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...SPTechCon
 
Create Home Directories on Storage Using WFA and ServiceNow integration
Create Home Directories on Storage Using WFA and ServiceNow integrationCreate Home Directories on Storage Using WFA and ServiceNow integration
Create Home Directories on Storage Using WFA and ServiceNow integrationRutul Shah
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 

Semelhante a Red5workshop 090619073420-phpapp02 (20)

Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
 
RoR guide_p1
RoR guide_p1RoR guide_p1
RoR guide_p1
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Ruby On Rails Basics
Ruby On Rails BasicsRuby On Rails Basics
Ruby On Rails Basics
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Language Resource Processing Configuration and Run
Language Resource Processing Configuration and RunLanguage Resource Processing Configuration and Run
Language Resource Processing Configuration and Run
 
Sinatra
SinatraSinatra
Sinatra
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
High quality ap is with api platform
High quality ap is with api platformHigh quality ap is with api platform
High quality ap is with api platform
 
Spring tutorial
Spring tutorialSpring tutorial
Spring tutorial
 
Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5
 
Intro to Rack
Intro to RackIntro to Rack
Intro to Rack
 
Tuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paperTuning and optimizing webcenter spaces application white paper
Tuning and optimizing webcenter spaces application white paper
 
Rails
RailsRails
Rails
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
 
Create Home Directories on Storage Using WFA and ServiceNow integration
Create Home Directories on Storage Using WFA and ServiceNow integrationCreate Home Directories on Storage Using WFA and ServiceNow integration
Create Home Directories on Storage Using WFA and ServiceNow integration
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 

Último

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 

Último (20)

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 

Red5workshop 090619073420-phpapp02

  • 1.
  • 2. What is red5 • An Open Source Flash Media Server • Built on Java (Mina & Spring) • Uses RTMP (Real Time Messaging Protocol) • Streaming Audio/Video (FLV and MP3) • Recording Client Streams (FLV only) • Shared Objects • Live Stream Publishing • Remoting (AMF) • Multi-User Environments
  • 3. What you need to get started • Eclipse 3.1 • J2EE • Flash IDE/Flash Develop/Flex • Red5 ( http://svn1.cvsdude.com/osflash/red5_ ) For more info on red5 release visit: http://www.red5world.com/downloads
  • 4. Building an application Application Directory red5 -webapps -Application Name -WEB-INF (contains configuration files & classes) -src -lib -classes web.xml red5-web.xml red5-web.properties *Note: This structure will always be the same
  • 5. Building an application cont… A closer look at the WEB-INF directories WEB-INF - src (contains all .java, .js, .py, .rb, files used to build your app.) - lib (contains all jar files required ) - classes (contains the compiled class files from the src directory) web.xml (this is the main configuration file for your app) globalScope contextConfigLocation locatorFactorySelector parentContextKey log4jConfigLocation webAppRootKey
  • 6. Building an application cont… web.xml (view sample file) globalScope <context-param> <param-name>globalScope</param-name> <param-value>default</param-value> </context-param> contextConfigLocation Specifies the name(s) of handler configuration files for this application. Additionally, the handler configuration files specify the scope hierarchy for these classes. The path name given here can contain wildcards to load multiple files: <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/red5-*.xml</param-value> </context-param> locatorFactorySelector References the configuration file of the root application context which usually is “red5.xml”:: <context-param> <param-name>locatorFactorySelector</param-name> <param-value>red5.xml</param-value> </context-param>
  • 7. Building an application cont… web.xml (view sample file) parentContextKey Name of the parent context, this usually is “default.context”:: <context-param> <param-name>parentContextKey</param-name> <param-value>default.context</param-value> </context-param> log4jConfigLocation Path to the configuration file for the logging subsystem:: <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param> webAppRootKey Unique name for this application, should be the public name:: <context-param> <param-name>webAppRootKey</param-name> <param-value>/myapp</param-value> </context-param>
  • 8. Building an application cont… red5-web.xml (view sample file) Handler configuration Every handler configuration file must contain at least three beans: 1. Context (The context bean has the reserved name web.context and is used to map paths to scopes, lookup services and handlers.) By default this bean is specified as: <bean id="web.context" class="org.red5.server.Context" autowire="byType" /> Every application can only have one context. However this context can be shared across multiple scopes. 2. Scopes Every application needs at least one scope that links the handler to the context and the server. The scopes can be used to build a tree where clients can connect to every node and share objects inside this scope (like shared objects or live streams). You can see the scopes as rooms or instances. The default scope usually has the name web.scope, but the name can be chosen arbitrarily.
  • 9. Building and application cont… red5-web.xml (view sample file) 2. Scopes cont… The bean has the following properties: • server (This references the global server) • red5.server. parent (References the parent for this scope and usually is global.scope.) • context (The server context for this scope, use the web.context from above.) • handler (The handler for this scope (see below)) • contextPath (The path to use when connecting to this scope.) • virtualHosts (A comma separated list of hostnames or IP addresses this scope runs at.) Sample definition: <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>
  • 10. Building an application cont… red5-web.xml (view sample file) 3. Handlers Every context needs a handler that implements the methods called when a client connects to the scope, leaves it and that contains additional methods that can be called by the client. Sample implementation: org.red5.server.adapter.ApplicationAdapter The bean for a scope handler is configured by: <bean id="web.handler“ class="the.path.to.my.Application“ singleton="true" /> The id attribute is referenced by the scope definition above. If you don't need any special server-side logic, you can use the default application handler provided by Red5: <bean id="web.handler“ class="org.red5.server.adapter.ApplicationAdapter“ singleton="true" />
  • 11. Building an application cont… red5-web.xml (view sample file) 3. Handlers cont… Sample handler: 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; } } You can call this method using the following ActionScript: nc = new NetConnection(); nc.connect("rtmp://localhost/myapp"); nc.onResult = function(obj) { trace("The result is " + obj); } nc.call("add", nc, 1, 2);
  • 12. red5 and AS3 How to build a red5 applications in AS3 (using the oflaDemo) ( view .fla ) /////////////////////////////////////////////////////////////////////////////////////////////////////// // Initialize Connection ////////////////////////////////////////////////////////////////////////////////////////////////////// nc = new NetConnection(); nc.client = this; nc.addEventListener(NetStatusEvent.NET_STATUS, onConnectHandler); nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onConnectErrorHandler); nc.connect("rtmp://localhost/oflaDemo"); remote_so = SharedObject.getRemote("chat"+roomNum, nc.uri, false); remote_so.addEventListener(SyncEvent.SYNC, onSyncHandler); remote_so.connect(nc); At this point you call your shared object „remote_so‟ anywhere in your AS to build functions around it, store data, retrieve date, etc..
  • 13. red5 and AS3 How to build a red5 applications in AS3 (using the oflaDemo) ( view .fla ) Here’s an example of how we call our shared object: function loginUser():void { if (remote_so.data.userArray == undefined) { userArray = new Array(); } else { userArray=remote_so.data.userArray; } userArray.push({name:userName}); remote_so.setProperty("userArray", userArray); remote_so.setProperty("chatText", chatInputWin.chatInput.text); remote_so.setDirty("userArray"); }
  • 14. Coding custom functions in red5 Let‟s take a look at how to code a custom java function in red5 that we can call later in ActionScript. *Note: We will be modifying the oflaDemo app (Application.java) JAVA SIDE FIRST: add some code to onconnect and ondisconnect inside... public boolean appConnect(IConnection conn, Object[] params) add... conn.getClient().setAttribute("name",params[0]); inside... public void appDisconnect(IConnection conn) add... String name=(String)conn.getClient().getAttribute("name"); Iterator<IConnection> conns3 = appScope.getConnections(); while(conns3.hasNext()) { try{ //to notify clients IConnection conn1=conns3.next(); ((IServiceCapableConnection)conn1).invoke("userClose",new Object[]{name},this); } catch(Exception e){} }
  • 15. Coding custom functions in red5 JAVA cont… Now we add some imports: import java.util.Iterator; import org.red5.server.api.service.IServiceCapableConnection; import org.red5.server.api.service.IPendingServiceCall; import org.red5.server.api.service.IPendingServiceCallback; Then we will add to our declaration: class Application extends ApplicationAdapter implements IPendingServiceCallback { Then we will need to add one method to our java: public void resultReceived(IPendingServiceCall call) {} Now we can compile it!
  • 16. Coding custom functions in red5 JAVA cont… Now we can call our new function/method in ActionScript ("userClose“) function userClose(name:String):void{ //Do something } That’s all there is to it!
  • 17. Resources • http://www.red5world.com • http://osflash.org/red5 • http://www.nabble.com/Red5-f16328.html • http://www.springframework.org • http://mina.apache.org References: Daniel Rossi – Red5 Documentation PDF OSFlash Red5 Wiki OsFlash Red5 Mailer List