FluorineFX开源库 使用教程

字体大小: 小 中 大
作者: ddv | 分类: 网站开发 | 浏览: 401 | 评论: 暂时没有评论
转载请保留出处: DDV=敌敌畏 www.dplayer.net

关于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.dplayer.net/post/31.html

FluorineFX开源库 使用教程(service配置xml说明)相关推荐

  1. 如何创建一个开源Javascript库 | Lynda教程 中文字幕

    如何创建一个开源Javascript库 | Lynda教程 中文字幕 Creating an Open Source JavaScript Library 课程ID: 604269 时长: 5.5小时 ...

  2. 【Android 安全】DEX 加密 ( 代理 Application 开发 | 项目中配置 OpenSSL 开源库 | 使用 OpenSSL 开源库解密 dex 文件 )

    文章目录 一.项目中配置 OpenSSL 开源库 二.OpenSSL 开源库解密参考代码 三.解密 dex 文件的 Java 代码 四.解密 dex 文件的 Jni 代码 参考博客 : [Androi ...

  3. vba xml 怎么设置父节点_熊二做了一个xml报文处理的开源库easyxml

    ❝ 自信.冷静.专注.-- TM 熊的自我勉励 ❞ 1. 前言 熊二从去年开始,因项目需求接触到xml报文的处理,也是我第一次学习用C/C++的方式处理基于DOM模型的xml报文.因为本人比较懒hhh ...

  4. STM32F103C8T6基础开发教程(HAL库)—开发环境配置

    STM32F103C8T6基础开发教程目录 STM32F103C8T6基础开发教程(HAL库)-开发环境配置 STM32F103C8T6基础开发教程(HAL库)-Keil添加注释的快捷键 STM32F ...

  5. Cubemx与HAL库系列教程|系统时钟配置详解及源码分析

    STM32时钟系统简介 STM32种类繁多,时钟系统也不尽相同,但基本的还是大差不差,今日小飞哥就F1系列的MCU简单聊一聊STM32的时钟系统 1.时钟种类介绍: 先来看一看时钟树图,包含了整个系统 ...

  6. 开源OA协同办公平台搭建教程:开源O2OA中log4j2使用配置

    O2OA应用开发平台是兰德纵横网络技术股份有限公司精心打造的一款开源办公产品,是使用JavaEE技术栈,分布式架构设计的真正全代码开源的企业应用定制化开发平台,平台既可以支持小企业的OA协同办公系统快 ...

  7. Android开源项目以及开源库集合(持续更新中)

    UI Awesome-MaterialDesign – MaterialDesignCenter改名为Awesome-MaterialDesign,优化了布局,新增了不少库. awesome-andr ...

  8. iOS开发--开源库

    图像: 1.图片浏览控件MWPhotoBrowser  实现了一个照片浏览器类似 iOS 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等操作. ...

  9. Android开源库总结

    自己总结的Android开源项目及库. github排名https://github.com/trending, github搜索:https://github.com/search UI Aweso ...

最新文章

  1. php 自定义表格并统计,PHP 使用Echarts生成数据统计报表的实现
  2. NLP最新资源:论文、代码、博客、视频一应俱全
  3. 类的方法(通过引用来传递参数)
  4. 联想拯救者15isk装win10系统_笔记本电脑触摸板操作手势合集以拯救者Win10系统为例...
  5. 关于Business Document save时是否设置distribution lock的问题
  6. py获取前端的参数_微前端 qiankun 项目实践
  7. 场景应用题目常见面试真题详解
  8. 如何终止Java线程
  9. php array函数 array_filter 过滤数组中的空值
  10. 产品体验报告:在行APP分析
  11. Android后台播放音乐(含通知栏操作)
  12. Android 10.0在电话拨号盘(Dialer app中)通过暗码进入工厂测试模式
  13. JS鼠标移入移出事件:onmouseover事件和onmouseout事件实例
  14. Cad二次开发小工具
  15. 大众点评的大数据实践转
  16. LTE 随机接入 --(1)流程
  17. Android 仿QQ 聊天消息拖拽效果
  18. 奥数计算机竞赛试题,奥数试卷
  19. C语言入门题库——编写求圆面积和球体积的函数
  20. zt陈辉生:登陆澳洲两周年记

热门文章

  1. Kepserver-数据点表配置导入导出
  2. python爬取贴吧数据_爬取百度贴吧数据(练习Python爬虫)
  3. 移动互联网4种引流思维:免费思维、跨界思维、平台思维、金融思维
  4. 计算机职高班教育故事,职高我的教育故事
  5. 运维之道 | SCP:Linux服务器之间传输目录文件
  6. 【计算机系统要素】使用Nand实现各种基本逻辑门
  7. 获取摄像头和麦克风权限_APP在偷偷调用摄像头、麦克风?你有权知道谁在这么做...
  8. 4G与5G网络有哪些区别
  9. 众至上网行为管理,管控内网行为,提升安全水平
  10. 【亡羊补牢】挑战数据结构与算法 第19期 LeetCode 212. 单词搜索 II(字典树,附上JS模板)