[英]How can I use the variable {server.name} in services-config.xml from AIR?
我正在將應用程序從 Flex/Flash 轉換為 Flex/AIR。 該應用程序進行消息傳遞。 我使用 services-config.xml 文件來定義通道和端點。
在 services-config.xml 中使用端點定義時,我通常使用;
<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>
在 AIR 中運行時,它會轉換為 SWF 文件的名稱(奇怪的是減去了第一個字符)。 我需要在運行時定義服務器的名稱。
我在應用程序的創建完整部分中嘗試了以下代碼;
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";
}
這似乎不起作用。
似乎唯一可行的是將 services-confg.xml 文件更改為;
<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>
然后編譯應用程序。 不幸的是,這意味着應用程序的生產版本將需要使用來自測試的不同 services-config.xml 文件進行編譯。
我正在尋找/需要的是一種在運行時定義服務器和端口的方法。
當我發布問題時,我幾乎就在那里,但我忘記了一點。
我解決它的方法是在運行時在我的動作腳本中使用它來修改 ServerConfig。
ServerConfig.getChannel("my-amf").uri = "http://Myserver.com:80/gateway,aspx";
ServerConfig.getChannel("my-rtmp").uri = "http://Myserver.com:1935";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.