Flex / .NET:使用FluorineFX的简单聊天应用程序

时间:2009-06-26 12:44:16

标签: .net flex fluorinefx

我正在尝试使用FluorineFX在Flex / .Net中创建一个非常简单的聊天应用程序但无法使其工作。

<mx:VBox
    width="100%"
    height="100%"
    xmlns:mx="http://www.adobe.com/2006/mxml">

<mx:Style source="../../../Monkeywrench.css"/>

<mx:Script>
<![CDATA[

import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.messaging.*;
import mx.messaging.messages.*;
import mx.messaging.events.*;
import mx.core.Application;

private function messageHandler(event:MessageEvent):void
{
    txtLog.text += event.message.body.userId + ": " + event.message.body.text + "\n";
}

private function messagefaultHandler(event:MessageFaultEvent):void
{
    Alert.show(event.faultString, "Error");
}

public function sendMessage():void
{
    var message:AsyncMessage = new AsyncMessage();
    message.body = {userId: Application.application.auth.user.Email, text: txtOutput.text}
    producer.send(message);
    txtOutput.text="";
}

]]>
</mx:Script>

<mx:Consumer id="consumer" destination="chat" message="messageHandler(event)" fault="messagefaultHandler(event)"/>
<mx:Producer id="producer" destination="chat" fault="messagefaultHandler(event)"/>

<mx:TextArea height="100%" width="100%" editable="false" id="txtLog"/>

<mx:HBox width="100%">

    <mx:TextInput width="100%" id="txtOutput"/>
    <mx:Button label="Skicka" click="sendMessage()"/>

</mx:HBox>

</mx:VBox>

我的services-config.xml:

<?xml version="1.0" encoding="utf-8" ?>
<services-config>
    <services>

        <service id="message-service" class="flex.messaging.services.MessageService" messageTypes="flex.messaging.messages.AsyncMessage">
            <adapters>
                <adapter-definition id="messagingAdapter" class="FluorineFx.Messaging.Services.Messaging.MessagingAdapter" default="true"/>
            </adapters>
            <destination id="chat">
                <adapter ref="messagingAdapter"/>
                <channels>
                    <channel ref="my-rtmp"/>
                </channels>
                <properties>
                    <network>
                        <session-timeout>20</session-timeout>
                    </network>
                    <server>
                        <allow-subtopics>true</allow-subtopics>
                    </server> 
                </properties>
                <!--
                <security>
                    <security-constraint ref="privileged-users"/>
                </security>
                -->
            </destination>
        </service>

    </services>

    <channels>

        <channel-definition id="my-rtmp" class="mx.messaging.channels.AMFChannel">
            <endpoint uri="rtmp://{server.name}:1950" class="flex.messaging.endpoints.RTMPEndpoint"/>
        </channel-definition>

    </channels>
</services-config>

它正在编译所有罚款,当我尝试发送时,我没有得到任何错误,但也没有结果。没有收到任何消息。我在正确的道路上吗?端点uri背后的逻辑是什么?我应该使用什么端口?我应该配置Web.config吗? (除了启用RemotingService的flourinefx配置之外?)我在flourine.log中没有得到任何响应。

1 个答案:

答案 0 :(得分:2)

您不能将AMFChannel / AMFEndpoint用于RTMP。请尝试使用services-config.xml中的以下代码:

<channel-definition id="channelRtmp" class="mx.messaging.channels.RTMPChannel">
    <endpoint uri="rtmp://{server.name}:1935" class="flex.messaging.endpoints.RTMPEndpoint"/>
</channel-definition>