我正在尝试让 RTMP 消息传递应用程序在FlashDevelop和FluorineFx中工作。我习惯于在 FlexBuilder 3 中使用一些骇客来连接 NetConnection,但我正在画一个空白,让它与 FlashDevelop 一起工作。
我有一个带有配置文件 \WEB-INF\flex\services-config 的 FluorineFx 网站
<?xml version="1.0" encoding="utf-8" ?>
<services-config>
<services>
<service-include file-path="remoting-config.xml" />
<service id="message-service" class="flex.messaging.services.MessageService" messageTypes="flex.messaging.messages.AsyncMessage">
<!-- DO NOT CHANGE <adapters> SECTION-->
<adapters>
<adapter-definition id="messagingAdapter" class="FluorineFx.Messaging.Services.Messaging.MessagingAdapter" default="true"/>
</adapters>
<destination id="chat">
<adapter ref="messagingAdapter"/>
<properties>
<network>
<session-timeout>0</session-timeout>
</network>
</properties>
<channels>
<channel ref="my-rtmp"/>
</channels>
</destination>
</service>
<!-- <service-include file-path="data-management-config.xml" /> -->
</services>
<!-- Custom authentication -->
<security>
</security>
<channels>
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint uri="http://{server.name}:{server.port}/{context.root}/Gateway.aspx" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<!--<legacy-collection>true</legacy-collection> -->
</properties>
</channel-definition>
<channel-definition id="my-rtmp" class="mx.messaging.channels.RTMPChannel">
<endpoint uri="rtmp://{server.name}:1951" class="flex.messaging.endpoints.RTMPEndpoint"/>
</channel-definition>
</channels>
</services-config>
我的 client.swf 文件在我网站上的目录 \apps\chat 中运行
在 apps\chat 目录中,我有一个 App.config 文件:
<configuration>
<!-- Application object. Specify a fully qualified type name for your handler -->
<application-handler type="testfx.AppHandler"/>
<!-- Filename generator for streams. Specify a fully qualified type name to use a custom generator-->
<streamFilenameGenerator type="FluorineFx.Messaging.Rtmp.Stream.DefaultStreamFilenameGenerator"/>
<consumerService type="FluorineFx.Messaging.Rtmp.Stream.ConsumerService"/>
<providerService type="FluorineFx.Messaging.Rtmp.Stream.ProviderService"/>
<streamService type="FluorineFx.Messaging.Rtmp.Stream.StreamService"/>
<!-- Manages creation, retrieval and update of remote shared objects-->
<sharedObjectService type="FluorineFx.Messaging.Rtmp.SO.SharedObjectService">
<persistenceStore type="FluorineFx.Messaging.Rtmp.Persistence.FileStore"/>
</sharedObjectService>
<!--
<sharedObjectSecurityService type=""/>
-->
</configuration>
testfx.AppHandler 类只有一个 echo 方法:
public class AppHandler : ApplicationAdapter
{
public string echo(string msg)
{
return "Echo: " + msg;
}
}
我有一个带有以下 .swc 库的 FlashDevelop 项目
- 框架.swc
- RPC.swc
- rpc_rb.swc
main.as 文件是:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.NetStatusEvent;
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
import mx.messaging.channels.*;
import mx.messaging.Consumer;
import mx.messaging.events.MessageEvent;
import mx.messaging.events.MessageFaultEvent;
import mx.messaging.Producer;
/**
* ...
* @author Nathan
*/
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var consumer:Consumer = new Consumer();
consumer.destination = "chat";
consumer.addEventListener(MessageEvent.MESSAGE, messageHandler);
consumer.addEventListener(MessageFaultEvent.FAULT, faultHandler);
consumer.subscribe();
var producer:Producer = new Producer();
producer.destination = "chat";
producer.addEventListener(MessageFaultEvent.FAULT, faultHandler);
producer.connect();
}
private function faultHandler(event:MessageFaultEvent):void
{
trace("fault");
}
private function messageHandler(event:MessageEvent):void
{
trace(event.message.body);
}
private function onNetStatus(event:NetStatusEvent):void
{
trace(event.info.code);
}
}
}
当我运行它时,我得到的当前异常是:
[Fault] 异常,information=[MessagingError message='Destination 'chat' 要么不存在,要么目的地没有定义频道(并且应用程序没有定义任何默认频道。)']