xiaoqiu369

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  7 Posts :: 3 Stories :: 2 Comments :: 0 Trackbacks
call.fla:

 1nc = new NetConnection();
 2nc.connect("rtmp://localhost/red5");
 3nc.onResult = function(obj) {
 4    var arr:Array=new Array();
 5    arr=obj;
 6    trace("obj="+arr.length);
 7    for(var i:Number=0;i<arr.length;i++){
 8        trace("arr"+[i]+":"+arr[i].user_name+"  "+arr[i].age);
 9    }

10        
11    if(obj==1){
12        resultTxt.text="用户名密码正确!";
13    }
else{
14        resultTxt.text="请输入user,pwd!";
15    }

16    trace("返回的值是:"+obj);
17    
18    dataGrid.dataProvider=arr;
19    dataGrid.editable=true;
20    dc.selectableRange={rangeStart:new Date(2003,9,15),rangeEnd:new Date(2003,11,31)}
21
22    
23}
;
24button.onRelease = function() {
25    //username password
26    nc.call("login", nc, username.text, password.text);
27}
;
28


user.java
 1package org.red5.core.vo;
 2
 3public class User {
 4    private int id;
 5    private String user_name;
 6    private int age;
 7    public int getId() {
 8        return id;
 9    }

10    public void setId(int id) {
11        this.id = id;
12    }

13    public String getUser_name() {
14        return user_name;
15    }

16    public void setUser_name(String user_name) {
17        this.user_name = user_name;
18    }

19    public int getAge() {
20        return age;
21    }

22    public void setAge(int age) {
23        this.age = age;
24    }

25    
26}


Application.java

 1package org.red5.core;
 2
 3import java.sql.ResultSet;
 4import java.sql.SQLException;
 5import java.util.Iterator;
 6import java.util.List;
 7
 8import javax.sql.DataSource;
 9
10import org.red5.core.vo.User;
11import org.red5.server.adapter.ApplicationAdapter;
12import org.red5.server.api.Red5;
13import org.red5.server.api.stream.IStreamAwareScopeHandler;
14import org.springframework.jdbc.core.JdbcTemplate;
15import org.springframework.jdbc.core.RowMapper;
16
17public class Application extends ApplicationAdapter implements IStreamAwareScopeHandler {
18    
19    public List login(String username,String password){
20        System.out.println("username="+username+";pwd="+password);
21        Object o=Red5.getConnectionLocal().getScope().getContext().getBean("dataSource");
22        JdbcTemplate jdbcTemplate=new JdbcTemplate((DataSource)o);
23        List list=jdbcTemplate.query("select * from users",new RowMapper(){
24
25            public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
26                User user=new User();
27                user.setId(rs.getInt(1));
28                user.setUser_name(rs.getString("user_name"));
29                user.setAge(rs.getInt("age"));
30                return user;
31            }

32            
33        }
);
34        for(int i=0;i<list.size();i++){
35            User user=(User)list.get(i);
36            System.out.println("username="+user.getUser_name());
37        }

38        System.out.println("username1="+username+";pwd1="+password);
39        if(username.equals("user")&&password.equals("pwd")){
40            return list;
41        }
else{
42            return list;
43        }

44    }

45}

46


applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd"
>

<beans>
    
<!--sql server connection-->
    
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        
<property name="url" value="jdbc:mysql://localhost:3306/test"/>
        
<property name="username" value="root"/>
        
<property name="password" value="admin"/>
    
</bean>
    

</beans>
red5-web.propertiest
1webapp.contextPath=/red5
2webapp.virtualHosts=localhost, 127.0.0.1

red5-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    
    
<!--
    Defines a properties file for dereferencing variables
    
-->
    
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        
<property name="location" value="/WEB-INF/red5-web.properties" />
    
</bean>
    
    
<!--
    Defines the web context
    
-->
    
<bean id="web.context" class="org.red5.server.Context" 
        autowire
="byType" />
    
    
<!--
    Defines the web scopes
    
-->
    
<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="${webapp.contextPath}" />
        
<property name="virtualHosts" value="${webapp.virtualHosts}" />
    
</bean>

    
<!--
    Defines the web handler which acts as an applications endpoint
    
-->
    
<bean id="web.handler" 
        class
="org.red5.core.Application" 
        singleton
="true" />
 
</beans>

web.xml
 1<?xml version="1.0" encoding="ISO-8859-1"?>
 2<web-app 
 3   xmlns="http://java.sun.com/xml/ns/j2ee" 
 4   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 5   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
 6   version="2.4"> 
 7
 8    <display-name>My sample Red5 application</display-name>
 9
10    <context-param>
11        <param-name>globalScope</param-name>
12        <param-value>default</param-value>
13    </context-param>
14
15    <context-param>
16        <param-name>contextConfigLocation</param-name>
17        <param-value>/WEB-INF/red5-*.xml,/WEB-INF/applicationContext.xml</param-value>
18    </context-param>
19
20    <context-param>
21        <param-name>locatorFactorySelector</param-name>
22        <param-value>red5.xml</param-value>
23    </context-param>
24
25    <context-param>
26        <param-name>parentContextKey</param-name>
27        <param-value>default.context</param-value>
28    </context-param>
29    
30    <!-- context-param>
31        <param-name>log4jConfigLocation</param-name>
32        <param-value>/WEB-INF/log4j.properties</param-value>
33    </context-param-->
34    
35    <context-param>
36        <param-name>webAppRootKey</param-name>
37        <param-value>/red5</param-value>
38    </context-param>
39    
40    <!-- listener>
41        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
42    </listener-->
43    
44    <listener>
45        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
46    </listener>
47
48    <!-- remove the following servlet tags if you want to disable remoting for this application -->
49    <servlet>
50        <servlet-name>gateway</servlet-name>
51        <servlet-class>org.red5.server.net.servlet.AMFGatewayServlet</servlet-class>
52    </servlet>
53    
54    <servlet-mapping>
55        <servlet-name>gateway</servlet-name>
56        <url-pattern>/gateway</url-pattern>
57    </servlet-mapping>
58
59    <security-constraint>
60        <web-resource-collection>
61            <web-resource-name>Forbidden</web-resource-name>
62            <url-pattern>/streams/*</url-pattern>
63        </web-resource-collection>
64        <auth-constraint/>
65    </security-constraint>
66
67</web-app>
68
posted on 2008-12-21 22:12 bobqiu 阅读(1630) 评论(0)  编辑  收藏 所属分类: red5&as

只有注册用户登录后才能发表评论。


网站导航: