I am converting an application from Flex/Flash to Flex/AIR. The application does messaging. I use the services-config.xml file to define channels & endpoints.
When using the endpoint definition in the services-config.xml I typically use;
<channels>
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint uri="http://{server.name}:{server.port}/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}:1935" class="flex.messaging.endpoints.RTMPEndpoint"/>
</channel-definition>
</channels>
When running in AIR this is translated to the name of the SWF file (minus the first character oddly). I need to define at runtime the name of the server.
I have tried the following code in my creation complete section of the application;
RootDomain = "http://192.168.144.190/";
if (bolTestMode == false)
{
var strRTMPuri:String = RootDomain.substr(0, RootDomain.length - 1) + ":1935";
strRTMPuri = strRTMPuri.toLowerCase().replace("http:","rtmp:");
ServerConfig.getChannel("my-rtmp").uri = strRTMPuri;
ServerConfig.getChannel("my-amf").uri = RootDomain.substr(0, RootDomain.length - 1) + ":80";
}
Which does not seem to work.
The only thing which does seem to work is changing the services-confg.xml file to;
<channels>
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint uri="http://192.168.144.190:{server.port}/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://192.168.144.190:1935" class="flex.messaging.endpoints.RTMPEndpoint"/>
</channel-definition>
</channels>
and then compiling the application. Unfortunately this means that the production version of the application will need to be compiled with a different services-config.xml file, from testing.
What i am looking for/need is a method to define the server & ports at runtime.