365体育投注官网
    成都做网站,就选365体育投注官网!专业四川网站建设,成都网站建设服务提供商
            企业宣传网站建设、电子商务网站建设、OA办公系统。联系电话:134 5869 5520

文章详情

FluorineFX开源库

关于FluorineFX

FluorineFX是一个开源库,提供了一种在.NET framework下对Flex/Flash的远程过程调用,Flex数据服务和实时数据的使用技术。
 

能被.NET frameworks支持的FluorineFx有:
 

Microsoft .NET Framework 1.1 (1.1.4322)
Microsoft .NET Framework 2.0 (2.0.50727)
Microsoft .NET Framework 3.5 (3.5.21022.8)
 Mono 1.2.4
.NET frameworks 支持向下兼容,所以新版本的框架将运行的二进制集会被定位到先前版本的框架
  特性

Flex, Flash Remoting (RPC)
Flex Messaging (partial)
Flex Data Services (partial)
Supports AMF0, AMF3 and RTMP protocols
Service Browser
Template based code generator (ASP.NET like syntax)
Easily integrate rich Internet applications with .NET backend
Easily integrate with Adobe Integrated Runtime (Adobe AIR™)
 

FluorineFx的配置

 

使用“FluorineFx Asp.net Web site”向导生成的项目结构如下:

 

除了编写.net服务器端代码,Flex客户端代码。还有非常重要的就是正确的设置配置文件。配置文件将指导如何将客户端的请求重定向到正确的服务器对象(代码中体现不出来)。

打开项目根目录下的web.config。系统向导默认的配置与fluorinefx相关的部分(其他的省略了)如下:

<?xml version="1.0" encoding="utf-8" ?><configuration> fluorinefx  <configSections>    <sectionGroup name="fluorinefx">      <section name="settings" type="FluorineFx.Configuration.XmlConfigurator, FluorineFx" requirePermission="false" />    </sectionGroup>  </configSections>   <fluorinefx>    <settings>      <!--  Reflection optimizer provider="codedom|il" debug="true|false" -->      <optimizer provider="codedom" debug="true"/>      <wsdlGenerateProxyClasses>true</wsdlGenerateProxyClasses>      <wsdlProxyNamespace>FluorineFx.Proxy</wsdlProxyNamespace>      <!--  Time Zone Compensation ="none|auto" -->      <timezoneCompensation>none</timezoneCompensation>      <!--  Any value-type that is not explicitly initialized with a value will contain the default value for that object type -->      <acceptNullValueTypes>false</acceptNullValueTypes>      <!-- value="browse|access" -->      <remotingServiceAttribute>access</remotingServiceAttribute>      <classMappings>        <classMapping>          <type>SampleClassNet</type>          <customClass>SampleClassAS</customClass>        </classMapping>      </classMappings>      <services>        <service>          <name>ServiceName</name>          <service-location>.NET Full type name</service-location>          <methods>            <remote-method>              <name>MethodName</name>              <method>.NET Method name</method>            </remote-method>          </methods>        </service>      </services>      <!-- 如果services-config.xml没有使用,才需要设置security部分-->      <security>        <login-command class="FluorineFx.Messaging.Security.GenericLoginCommand" server="asp.net"/>      </security>      <cache>        <cachedService timeout="30" slidingExpiration="false" type=".NET Full type name"/>      </cache>      <importNamespaces>        <add namespace="Namespace name to import" assembly=""/>      </importNamespaces>      <nullable>        <type name="System.Int32" value="MinValue"/>        <type name="System.Double" value="MinValue"/>        <type name="System.DateTime" value="MinValue"/>        <type name="System.Guid" value="Empty"/>      </nullable>      <!-- preferredAlgorithm="deflate|gzip" compressionLevel="high|normal|low" handleRequest="all|amf|none" -->      <httpCompress preferredAlgorithm="gzip" compressionLevel="high" handleRequest="all">        <!-- compress responses larger then threshold bytes-->        <threshold>10240</threshold>        <excludedMimeTypes>           <add type="image/jpeg"/>           <add type="image/png"/>           <add type="image/gif" />           <add type="application/zip" />           <add type="application/x-zip-compressed" />           <add type="application/x-gzip-compressed" />           <add type="application/x-compressed" />           <add type="application/octet-stream" />           <add type="application/pdf" />        </excludedMimeTypes>        <excludedPaths>           <!--Fluorine service browser scripts and resources -->           <add path="FluorineWebResource.axd"/>           <add path="FluorineCodeGenerator.aspx"/>           <!--standard .NET validating scripts and postback script -->           <add path="WebResource.axd"/>           <!--MS AJAX and has it's own compression module that will take care of the AJAX scripts -->           <add path="ScriptResource.axd"/>        </excludedPaths>      </httpCompress>      <application-handler>FluorineFx.Messaging.Adapter.ApplicationAdapter</application-handler>      <sharedObjectService type="FluorineFx.Messaging.Rtmp.SO.SharedObjectService">        <persistence type="FluorineFx.Messaging.Rtmp.Persistence.FileStore"/>      </sharedObjectService>      <fluorineContextFactory type="FluorineFx.Context.FluorineRtmpContextFactory"/>      <rtmpServer>        <threadpool minWorkerThreads="0" maxWorkerThreads="25" idleTimeout="60000"/>      </rtmpServer>    </settings>  </fluorinefx>   ...  <system.web>    <httpModules>      <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx" />    </httpModules>  </system.web>  ...</configuration>  

说明:其中,<fluorinefx />部分不是必须有的 ;<httpModules />中的"FluorineGateway" http module entry 必须有;如果没有使用services-config.xml配置文件,才需要设置<security />部分。

除了根目录下的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配置信息分散到多个配置文件里,然后包含进来以达到简化的效果。如下:

  <services>    <!-- Remoting Service -->    <service-include file-path="remoting-config.xml"/>    <!-- Message Service -->    <service-include file-path="messaging-config.xml"/>    <!-- Data Management Service -->    <service-include file-path="data-management-config.xml"/>  </services>下表是这四个配置文件的作用:

services-config.xml
 顶层的配置文件。包含有 Contains security constraint 定义, channel 定义, service 定义。
 
remoting-config.xml
 Remoting Service destination定义,用于访问remote objects。
 
messaging-config.xml
 Message Service destination定义,用于publish subscribe messaging。
 
data-management-config.xml
 Data Management Service destination定义。
 

看上去这些配置文件和Flex Data Service保持一致。没错,FluorineFx 配置文件与Flex/Flash保持了统一。

这四个XML格式的配置文件中可以使用的XML elements如下表:

XML element
 描述
 
services
 services-config是XML配置文件的根节点,而services是services-config的第一个字节点(属于配置的顶层元素)
 
services/service-include
 Includes files by reference that contain service definitions
 
services/service
 Definition for a service (Remoting Service, Message Service, Data Management Service)
 
services/service/properties
 Service-level properties
 
services/service/adapters
 Definitions for service adapters that are referenced in destinations
 
services/service/adapters/adapter-definition
 Service adapter definition
 
services/service/default-channels
 References to a service's default channels (when a channel is not explicitly referenced in a destination)
 
services/service/default-channels/channel
 References to the id of a channel definition
 
services/service/destination
 Destination definition
 
services/service/destination/adapter
 A reference to a service adapter
 
services/service/destination/properties
 Destination properties
 
services/service/destination/channels
 References to the channels that the service can use for data transport
 
services/service/destination/channels/channel
 References to the id of a channel definition
 
services/service/destination/security
 Complete security constraint definitions or references to security constraint definitions and login command definitions that are used for authentication and authorization
 
services/service/destination/security/security-constraint
 References to the id value of a security constraint definition or contains a security constraint definition
 
services/service/destination/security/security-constraint/roles
 Names of roles used for authorization
 
services/service/destination/security/login-command
 References to the id value of a login command definition that is used for performing custom authentication.

<!--[if !vml]--><!--[endif]-->Not supported
 
security
 Security constraint definitions and login command definitions for authentication and authorization
 
security/security-constraint
 Defines a security constraint
 
security/security-constraint/roles
 Names of roles used for authorization
 
security/login-command
 Defines a login command used for custom authentication
 
channels
 Definitions of message channels used to transport data between the server and clients
 
channels/channel-definition
 Defines a message channel to transport data
 
channels/channel-definition/endpoint
 Specifies the endpoint URI and the endpoint class of the channel definition
 
channels/channel-definition/properties
 Properties of a channel definition
 

在这些配置部分,有些针对于所有的全部的Service(在services-config.xml设置),有些则专用于特定的Service(在remoting-config.xml/ messaging-config.xml/ data-management-config.xml中设置)。

先看看services-config.xml中的全局设置部分:

1.配置message channel
FluorineFx 使用Flex messaging system 中的message channel传输消息。一个channel可以让多个Service通信。FluorineFx目前不支持AMF polling channels 。在services-config.xml配置文件中可以设置AMF Channel 或者RTMP Channel。如下:

<channels>

  <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">

<endpoint uri="http://{server.name}:{server.port}/{context.root}/Gateway.aspx"

 class="flex.messaging.endpoints.AMFEndpoint"/>

  </channel-definition>

  <channel-definition id="my-rtmp" class="mx.messaging.channels.RTMPChannel">

       <endpoint uri="rtmp://{server.name}:1951"    class="flex.messaging.endpoints.RTMPEndpoint"/>

  </channel-definition>

</channels>
 

这里用<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代码连接这个远程对象。

例如:

<service id="remoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage"><!-- Adapter 定义不是必须的,  gateway 会自动的创建它--><adapters>    <adapter id="dotnet" class="FluorineFx.Remoting.RemotingAdapter" default="true"/></adapters><default-channels>    <channel ref="my-amf"/></default-channels><!—下面定义一个Destination,也就是一个远程对象 --><destination id="EchoServiceRO"><!--  由于上面定义了一个默认的channel,则不需要再定义channel  <channels>     <channel ref="my-amf"/>  </channels>-->    <properties>    <source>ServiceLibrary.EchoService</source>    <!-- <scope>application</scope> -->  </properties>  <security>    <security-constraint ref="privileged-users"/>  </security></destination> ...<security>    <security-constraint id="privileged-users">        <auth-method>Custom</auth-method>        <roles>            <role>privilegedusers</role>             <role>admins</role>        </roles>     </security-constraint></security>... 对上面配置的说明:
1.<security>的安全设置
定义了远程对象,可以使用security constraint来限制用户访问访问这个destination (只支持custom authentication)。

Security constraints 可以在destination中定义,也可以在destination外面 定义,然后在destination中通过Security constraints的 id引用。

2.Destination adapter
Adapters是服务器上的一个组件,利用Adapter,客户端才能访问远程服务器上的 service object。 Adapter 定义不是必需的, gateway 将自动配置它。默认的Remoting Adapter是flex.messaging.services.RemotingService。

3.Remote object 的<properties>
Property element
 描述
 
source
 Fully qualified type name of the .NET object (remoting service)
 
scope
 可以设置为 request, application,  session。默认值为“ request”。

如果为“request”,则Objects是无状态的stateless (  remoting service object is instantiated for every request);如果为“application”,则整个application都可以访问这个object;

如果为“session”,则相同的session可以使用 (a single remoting service object is created per asp.net session).
 

4.Web service properties(还不支持)

Property element
 描述
 
wsdl
 不支持
 
soap
 不支持
 

5.默认设置

如果没有service配置文件,则gateway会使用下面的默认配置:

<?xml version="1.0" encoding="UTF-8"?>

<factories>

   <factory id="dotnet" class="FluorineFx.Messaging.DotNetFactory"/>

</factories>

<services-config>

    <services>

       <service id="remoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage">

           <!--  所有的远程调用remote calls 都被路由到这个destination-->

           <destination id="fluorine">

               <channels>

                   <channel ref="my-amf"/>

               </channels>

               <properties>

                   <source>*</source>

               </properties>

           </destination>

      <!--  只有在Service Browsing打开的情况下,下面的destination才创建 -->      

    <!--  This destination is created only when Service Browsing is enabled-->

           <destination id="FluorineFx.ServiceBrowser.FluorineServiceBrowser">

               <channels>

                   <channel ref="my-amf"/>

               </channels>

               <properties>

                   <source>FluorineFx.ServiceBrowser.FluorineServiceBrowser</source>

               </properties>

           </destination>

           <!-- This destination is created only when Service Browsing is enabled-->

           <destination id="FluorineFx.ServiceBrowser.ManagementService">

               <channels>

                   <channel ref="my-amf"/>

               </channels>

               <properties>

                   <source>FluorineFx.ServiceBrowser.ManagementService</source>

               </properties>

           </destination>

           <!-- This destination is created only when Service Browsing is enabled-->

           <destination id="FluorineFx.ServiceBrowser.CodeGeneratorService">

               <channels>

                   <channel ref="my-amf"/>

               </channels>

               <properties>

                   <source>FluorineFx.ServiceBrowser.CodeGeneratorService</source>

               </properties>

           </destination>

       </service>

 

   </services>

 

   <!-- This is the LoginCommand specified in the web-config file if applicable-->

   <security>

      <login-command class="..." server="asp.net"/>

   </security>

 

   <channels>

        <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">

            <endpoint uri="http://{server.name}:{server.port}/{context.root}/Gateway.aspx" class="flex.messaging.endpoints.AMFEndpoint"/>

        </channel-definition>

   </channels>

</services-config>
 

 

 

二、配置 Message Service
Message Service destination 是就是消息传输的终端(endpoint)。在这台终端机上封装有服务器端代码,处理传输过来的消息 。使用 Producer 和Consumer 组件或ActionScript API可以连接到message service destination。

例如:

<service id="message-service" class="flex.messaging.services.MessageService" messageTypes="
flex.messaging.messages.AsyncMessage"><adapters>    <adapter id="chat" class="ServiceLibrary.ChatAdapter" default="true"/></adapters> <destination id="chat">    <channels>        <channel ref="my-rtmp"/>    </channels>    <properties>        <network>            <session-timeout>20</session-timeout>        </network>        <server>            <allow-subtopics>true</allow-subtopics>        </server>        <security>            <security-constraint ref="privileged-users"/>        </security>    <properties></destination></service>...<security>    <security-constraint id="privileged-users">        <auth-method>Custom</auth-method>        <roles>            <role>privilegedusers</role>             <role>admins</role>        </roles>     </security-constraint></security>... <channels>    <channel-definition id="my-rtmp" class="mx.messaging.channels.RTMPChannel">        <endpoint uri="rtmp://{server.name}:1951" class="flex.messaging.endpoints.RTMPEndpoint"/>    </channel-definition></channels>...对上面配置的说明:
1.Message channels
当前版本的FluorineFx 只支持通过Realtime Message Protocol (RTMP) channel传输消息。

2.Message Service adapter
在FluorineFx中,默认的 Message Service adapter就是FluorineFx.Messaging.Services.Messaging.MessagingAdapter 类。所以配置文件如下设置:

    <adapter id="dotnet" class="FluorineFx.Messaging.Services.Messaging.MessagingAdapter" default="true"/>如果编写MessagingAdapter类的子类,你就可以自己定义Adapter 。

3.Network properties
Property element
 Description
 
session-timeout
 超过这个时间(单位:分钟),a subscriber is unsubscribed。 (如果没有或者值为 0 ,则表明不会自动unsubscribe)
 

4.Server properties
Property element
 Description
 
allow-subtopics
 Destination是否支持subtopics (true/false)
 
subtopic-separator
 不支持。所以总是"." (点)
 

 

 

三、配置 Data Management Service
Data Management Service destination 是一个终端。这个终端可以接收数据,或者发送数据到客户机。它提供了将数据分布到多个Data Management Service destination和 在这些destination之间进行同步(synchronization)的能力。 在Flex中使用DataService 组件或ActionScript API可以连接到Data Management Service destination。

例子:

<service id="data-service" class="flex.data.DataService" messageTypes="flex.data.messages.DataMessage"><adapters>    <adapter id="dotnet-dao" class="FluorineFx.DotNetAdapter" default="true"/></adapters><default-channels>    <channel ref="my-rtmp"/></default-channels> <destination id="crm.company">    <adapter ref="dotnet-dao"/>    <properties>        <source>samples.crm.CompanyAssembler<source/>        <scope>application<scope/>        <metadata>            <identity property="companyId"/>        </metadata>        <network>            <session-timeout>20</session-timeout>            <paging enabled="true" pageSize="10"/>        </network>    </properties>    </destination></service>... <channels>    <channel-definition id="my-rtmp" class="mx.messaging.channels.RTMPChannel">        <endpoint uri="rtmp://{server.name}:1951" class="flex.messaging.endpoints.RTMPEndpoint"/>    </channel-definition></channels>...              

对上面配置的说明:
1.Message channel的选择:
当前的FluorineFx 只支持使用Realtime Message Protocol (RTMP) channel 传输Data Management Services。

2.Data adapter的设置:
FluorineFx中的 Data adapter是由 FluorineFx.DotNetAdapter 类实现的:

    <adapter id="dotnet" class="FluorineFx.DotNetAdapter" default="true"/>3.Destination properties
Property element
 描述
 
source
 Fully qualified type name of the Data Assembler
 
scope
 Valid values are request, application, and session. The default value is request.
 
cache-items
 不支持, 总设置成true
 
auto-sync-enabled
 不支持, 总设置成true
 

4.Network properties
Property element
 描述
 
session-timeout
 Idle time in minutes before a subscriber is unsubscribed (Missing element or the value 0 means do not unsubscribe automatically)
 
paging
 Optional element specifying data paging settings. The enabled attribute (true/false) indicates whether data paging is enabled for the destination, the pageSize attribute indicates the number of records in a page.
 

5.Metadata properties
Property element
 描述
 
identity
 Specifies data properties that provide object identity. The property attribute identifies the property name.
 

6.Server properties
Property element
 描述
 
allow-subtopics
 Specifies whether subtopics are allowed for a destination (true/false)
 
subtopic-separator
 Not supported. In FluorineFx the subtopic separator is always "." (period)
 
文章来源:http://www.airia.cn/AIR_FLEX_down/fluorinefx/

 



上一篇:FluorineFX 使用fluorinefx的感受

下一篇:Asp.net如何防止图片被盗链?

友情链接

首页  |  建站学院  |  网站建设  |  成功案例  |  业务体系  |  软件定制  |  解决方案  |  联系我们  |  免责声明
中成网建公司地址:四川省成都市双楠双安东巷1号18-3-5 电话:028-6616 5255 版权所有 @ 中成网建
成都网站建设网址:www.dowin-sourcing.com 邮箱:web#csccd.net
信息产业部备案号:蜀ICP备08106559号