關於FluorineFX FluorineFX是一個開源庫,提供了一種在.NET framework下對Flex/Flash的遠程過程調用,Flex數據服務和實時數據的使用技術。 能被.NET frameworks支持的FluorineFx有:
FluorineFx的配置 使用“FluorineFx ASP.net Web site”嚮導生成的項目結構如下: 除了根目錄下的web.config文件(asp.net網站的標準配置文件外),WEB-INF/flex目錄下還有四個配置文件(.xml)。 由於FluorineFx是Flex Data Service的.net替代品(如果你用Java寫服務器端程序,則可以直接用Flex Data Service),FluorineFx提供了和Flex Data Service相同的功能—即在services-config.xml配置文件的<services>部分配置Remoting Service, Message Service ,Data Management Service。 此外,除了把所有配置都放在services-config.xml一個文件中,還可以把Service配置信息分散到多個配置文件裏,然後包含進來以達到簡化的效果。如下: 下表是這四個配置文件的作用: 看上去這些配置文件和Flex Data Service保持一致。沒錯,FluorineFx 配置文件與Flex/Flash保持了統一。 在這些配置部分,有些針對於所有的全部的Service(在services-config.xml設置),有些則專用於特定的Service(在remoting-config.xml/ messaging-config.xml/ data-management-config.xml中設置)。 先看看services-config.xml中的全局設置部分: 1.配置message channelFluorineFx 使用Flex messaging system 中的message channel傳輸消息。一個channel可以讓多個Service通信。FluorineFx目前不支持AMF polling channels 。在services-config.xml配置文件中可以設置AMF Channel 或者RTMP Channel。如下: 這裏用<channel-definition>定義的channel,每個都有唯一的id。<endpoint>的uri設置的是一個接受用戶請求的網關(Gateway.aspx)程序。打開這個網關程序,你可以發現程序中沒有任何代碼。 Flex調用遠程對象的流程大概如下: <!--[if !supportLists]-->l <!--[endif]-->Flex發出調用遠程對象的請求,這個請求會被Flash Player編碼成AMF; <!--[if !supportLists]-->l <!--[endif]-->Flex代碼中定義了 Service組件,通過該組件的id,找到對應配置文件中定義的destination。 <!--[if !supportLists]-->l <!--[endif]-->destination通過它的channel 的 id找到對應的channel定義。 <!--[if !supportLists]-->l <!--[endif]-->根據channel的定義,將請求發送給指定的gateway; <!--[if !supportLists]-->l <!--[endif]-->gateway將請求發送給gateway的後臺類,將消息轉換成.net格式,調用服務器上正確的類; 接下來,針對Remoting Service, Message Service ,Data Management Service的配置分別進行詳細說明。 一、配置RPC(remoting-config.xml) 定義Remoting Service destination就是定義需要訪問的remote object。Remoting service destination就是一個對象,Flex使用<mx:RemoteObject>或 ActionScript代碼連接這個遠程對象。 例如: 對上面配置的說明:1.<security>的安全設置 定義了遠程對象,可以使用security constraint來限制用戶訪問訪問這個destination (只支持custom authentication)。 Security constraints 可以在destination中定義,也可以在destination外面 定義,然後在destination中通過Security constraints的 id引用。 2.Destination adapterAdapters是服務器上的一個組件,利用Adapter,客戶端才能訪問遠程服務器上的 service object。 Adapter 定義不是必需的, gateway 將自動配置它。默認的Remoting Adapter是flex.messaging.services.RemotingService。 3.Remote object 的<properties> 4.Web service properties(還不支持)5.默認設置 如果沒有service配置文件,則gateway會使用下面的默認配置: 二、配置 Message ServiceMessage Service destination 是就是消息傳輸的終端(endpoint)。在這臺終端機上封裝有服務器端代碼,處理傳輸過來的消息 。使用 Producer 和Consumer 組件或ActionScript API可以連接到message service destination。 例如: 對上面配置的說明:1.Message channels當前版本的FluorineFx 只支持通過Realtime Message Protocol (RTMP) channel傳輸消息。 2.Message Service adapter在FluorineFx中,默認的 Message Service adapter就是FluorineFx.Messaging.Services.Messaging.MessagingAdapter 類。所以配置文件如下設置: 如果編寫MessagingAdapter類的子類,你就可以自己定義Adapter 。 3.Network properties 4.Server properties 三、配置 Data Management ServiceData Management Service destination 是一個終端。這個終端可以接收數據,或者發送數據到客戶機。它提供了將數據分佈到多個Data Management Service destination和 在這些destination之間進行同步(synchronization)的能力。 在Flex中使用DataService 組件或ActionScript API可以連接到Data Management Service destination。 例子: 對上面配置的說明:1.Message channel的選擇:當前的FluorineFx 只支持使用Realtime Message Protocol (RTMP) channel 傳輸Data Management Services。 2.Data adapter的設置:FluorineFx中的 Data adapter是由 FluorineFx.DotNetAdapter 類實現的: |