Flex/.NET:使用 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 中没有得到任何响应。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能将 AMFChannel/AMFEndpoint 用于 RTMP。 尝试在 services-config.xml 中使用以下代码:
You can't use an AMFChannel/AMFEndpoint for RTMP. Try using the code below in services-config.xml instead: