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

发布于 2024-07-25 02:40:55 字数 3313 浏览 9 评论 0原文

我正在尝试使用 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 中没有得到任何响应。

I'm trying to create a very simple chat application in Flex/.Net using FluorineFX but can't get it to work.

<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>

My 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>

It's compiling all fine, and when I try to send I don't get any errors, but also no result. No message is received. Am I on the right path? What's the logic behind the endpoint uri? What port should I use? Should I configurate Web.config? (beyond the flourinefx configs that enable RemotingService?) I don't get any response in the flourine.log.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅沫记忆 2024-08-01 02:40:55

您不能将 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>

You can't use an AMFChannel/AMFEndpoint for RTMP. Try using the code below in services-config.xml instead:

<channel-definition id="channelRtmp" class="mx.messaging.channels.RTMPChannel">
    <endpoint uri="rtmp://{server.name}:1935" class="flex.messaging.endpoints.RTMPEndpoint"/>
</channel-definition>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文