views:

1233

answers:

2

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"&gt;

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

A: 

By change channel-definition to:

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

I get error message "the request destination chat is not accessible"

Niels Bosma
+1  A: 

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>
cliff.meyers