Форум Flasher.ru
Ближайшие курсы в Школе RealTime
Список интенсивных курсов: [см.]  
  
Специальные предложения: [см.]  
  
 
Блоги Правила Справка Пользователи Календарь Сообщения за день
 

Вернуться   Форум Flasher.ru > Flash > Серверные технологии и Flash

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему Ответ
Старый 10.12.2008, 18:52
VovkaMorkovka1 вне форума Посмотреть профиль Отправить личное сообщение для VovkaMorkovka1 Посетить домашнюю страницу VovkaMorkovka1 Найти все сообщения от VovkaMorkovka1
  № 1  
Ответить с цитированием
VovkaMorkovka1

Регистрация: Nov 2008
Сообщений: 205
По умолчанию Как написать HelloWorld для red5 v 7.0

Всем привет!
Разбираюсь с red5, запускаю приложение с помощью плагина к иклипсу.
В консоль данного плагина выводится, что приложение стартовало, однако полключится из флешового кода к моему приложению не удается.
Вопрос: что поправить, чтоб приложение заработало?

Ниже представлены файлы с java - кодом, flash - кодом и файлы настройки. Что не так, господа?


Вот Java класс
Код:
package org.red5.core;

/*
 * RED5 Open Source Flash Server - http://www.osflash.org/red5
 * 
 * Copyright (c) 2006-2007 by respective authors (see below). All rights reserved.
 * 
 * This library is free software; you can redistribute it and/or modify it under the 
 * terms of the GNU Lesser General Public License as published by the Free Software 
 * Foundation; either version 2.1 of the License, or (at your option) any later 
 * version. 
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along 
 * with this library; if not, write to the Free Software Foundation, Inc., 
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 */

import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.Red5;
import org.red5.server.api.service.ServiceUtils;
import org.red5.server.api.stream.IBroadcastStream;
import org.red5.server.api.stream.IStreamAwareScopeHandler;
import org.red5.server.framework.ClientManager;
import org.red5.server.framework.LayoutManager;
import org.red5.server.framework.StreamManager;
import org.red5.server.framework.*;

/**
 * Red5Server Framework.
 * 
 * @author The Red5 Project (red5@osflash.org)
 * @author Dominick Accattato
 * @author Joachim Bauch (jojo@struktur.de)
 */
public class Application extends ApplicationAdapter implements IStreamAwareScopeHandler {
	
	/** Manager for the clients. */
	private ClientManager clientMgr = new ClientManager("clientlist", false);
	private StreamManager streamMgr = new StreamManager("streamlist", false);
	private LayoutManager layoutMgr = new LayoutManager("layoutlist", false);
	
	public Application() {
		System.out.println("------ app have bin created --------------");
	}
	
	/** {@inheritDoc} */
    @Override
	public boolean connect(IConnection conn, IScope scope, Object[] params) {
    	System.out.println("--------------- connect ------------");
		// Check if the user passed valid parameters.
		if (params == null || params.length == 0) {
			// NOTE: "rejectClient" terminates the execution of the current method!
			rejectClient("No username passed.");
		}

		// Call original method of parent class.
		if (!super.connect(conn, scope, params)) {
			return false;
		}

		String username = params[0].toString();
		String uid = conn.getClient().getId();
		
		Client client = new Client();
		client.setUsername(username);
		client.setAge(100);
		client.setUid(uid);
		
		// Register the user in the shared object.
		clientMgr.addClient(scope, client);
		
		// Notify client about unique id.
		ServiceUtils.invokeOnConnection(conn, "setClientID",
				new Object[] { uid });
		return true;
	}

	/** {@inheritDoc} */
    @Override
	public void disconnect(IConnection conn, IScope scope) {
    	System.out.println("--------------- disconnect ------------");
		// Get the previously stored username.
		String uid = conn.getClient().getId();
		// Unregister user.
		String username = clientMgr.removeClient(scope, uid);
		
		// Call original method of parent class.
		super.disconnect(conn, scope);
	}

    @Override
	public void streamBroadcastClose(IBroadcastStream stream) {
    	System.out.println("--------------- streamBroadcastClose ------------");
		// TODO Auto-generated method stub
		super.streamBroadcastClose(stream);
		
		// Get connection and Scope
		IConnection conn = Red5.getConnectionLocal();
	    IScope scope = conn.getScope();
		
		streamMgr.removeStream(scope, stream.getName());
		
	}

	@Override
	public void streamBroadcastStart(IBroadcastStream stream) {
		System.out.println("--------------- streamBroadcastStart ------------");
		// TODO Auto-generated method stub
		super.streamBroadcastStart(stream);
		
		// Get connection and Scope
		IConnection conn = Red5.getConnectionLocal();
	    IScope scope = conn.getScope();
	    
	    streamMgr.addStream(scope, stream.getPublishedName(), stream.getName());
	    
	}

	@Override
	public void streamPublishStart(IBroadcastStream stream) {
		System.out.println("--------------- streamPublishStart ------------");
		// TODO Auto-generated method stub
		super.streamPublishStart(stream);
		
	}
	
}
Вот AS класс, с помощью которого я пытаюсь подконнектится к приложению

Код AS3:
package 
{
	import flash.net.NetConnection;
	import flash.net.ObjectEncoding;
	import flash.events.NetStatusEvent;
	import flash.display.Sprite;
 
	public class Red5FirstClient extends Sprite
	{
		private var nc:NetConnection;
 
		public function Red5FirstClient ()
		{
			nc = new NetConnection();
			nc.objectEncoding = ObjectEncoding.AMF0;
			nc.addEventListener( NetStatusEvent.NET_STATUS, netStatus );
			nc.connect('rtmp://localhost/red5helloworld:8080', true);
		}
 
		private function netStatus (event:NetStatusEvent):void
		{
			trace(event.info.code);
			if(event.info.code == 'NetConnection.Connect.Rejected')
			{
				trace(event.info.application);
			}
		}
	}
}
Файл RED5-INF проекта

Код:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
	
	<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
	    <property name="location" value="/WEB-INF/red5-web.properties" />
	</bean>
	
	<bean id="web.context" class="org.red5.server.Context" 
		autowire="byType" />
	
	<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>
	
	
	<bean id="web.handler" 
	    class="org.red5.core.Application" 
		singleton="true" />
 
</beans>
web.xml

Код:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 
   xmlns="http://java.sun.com/xml/ns/j2ee" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" 
   version="2.4"> 

	<display-name>Red5 tutorial</display-name>

	<context-param>
	    <param-name>globalScope</param-name>
	    <param-value>default</param-value>
	</context-param>

	<context-param>
	    <param-name>contextConfigLocation</param-name>
	    <param-value>/WEB-INF/red5-*.xml</param-value>
	</context-param>

	<context-param>
		<param-name>locatorFactorySelector</param-name>
		<param-value>red5.xml</param-value>
	</context-param>

	<context-param>
		<param-name>parentContextKey</param-name>
		<param-value>default.context</param-value>
	</context-param>
		
	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>red5helloworld</param-value>
	</context-param>
	
	<listener>
	    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

    <!-- remove the following servlet tags if you want to disable remoting for this application -->
	<servlet>
		<servlet-name>gateway</servlet-name>
		<servlet-class>
			org.red5.server.net.servlet.AMFGatewayServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
    
	<servlet-mapping>
		<servlet-name>gateway</servlet-name>
		<url-pattern>/gateway</url-pattern>
	</servlet-mapping>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Forbidden</web-resource-name>
            <url-pattern>/streams/*</url-pattern>
        </web-resource-collection>
        <auth-constraint/>
    </security-constraint>

</web-app>
Вот файл red5-web.properties

Код:
webapp.contextPath=/red5helloworld
webapp.virtualHosts=*, localhost, localhost:8088, 127.0.0.1:8088
Что у меня не так?

Добавлено через 6 часов 45 минут
Уже разобрался сам, проблема была в файле red5-web.properties

Для нормальной работы должно быть так

Код:
webapp.contextPath=/firstapp
webapp.virtualHosts=*, localhost, localhost:8088, 127.0.0.1:8088
После этого все корректно работает на шестой и на седьмой версии

Создать новую тему Ответ Часовой пояс GMT +4, время: 01:43.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


 


Часовой пояс GMT +4, время: 01:43.


Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.