FluorineFx.NET

Application Adapter

To write custom application code working with client connections, processing server-side events, calling client methods, enforcing security a custom Application Adapter must be implemented.

The FluorineFx.Messaging.Adapter.ApplicationAdapter class is used as base class for new applications. This class provides methods to work with connections, shared objects and streams.

Additionally the Application object has callback functions that are invoked when an application starts and stops and when a client connects and disconnects.

The Application Adapter is an application level scope handler.

Application configuration

Each messaging application can optionally include a configuration file located in the root directory of the application. The configuration file is named app.config.

A custom Application Adapter class must be registered in the application configuration file.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!-- Application object. Specify a fully qualified type name for your handler -->
  <application-handler type="FluorineFx.Messaging.Adapter.ApplicationAdapter"/>
  <!-- Filename generator for streams. Specify a fully qualified type name to use a custom generator-->
  <streamFilenameGenerator type="FluorineFx.Messaging.Rtmp.Stream.DefaultStreamFilenameGenerator"/>
  <consumerService type="FluorineFx.Messaging.Rtmp.Stream.ConsumerService"/>
  <providerService type="FluorineFx.Messaging.Rtmp.Stream.ProviderService"/>
  <streamService type="FluorineFx.Messaging.Rtmp.Stream.StreamService"/>
  <!-- Manages creation, retrieval and update of remote shared objects-->
  <sharedObjectService type="FluorineFx.Messaging.Rtmp.SO.SharedObjectService">
    <persistenceStore type="FluorineFx.Messaging.Rtmp.Persistence.FileStore"/>
  </sharedObjectService>
  <!-- 
  <sharedObjectSecurityService type=""/>
  -->
  
</configuration>		

Connecting to a messaging application

The NetConnection class connects a client to an application instance on the server.

var nc:NetConnection = new NetConnection();
var uri:String = "rtmp://localhost:1935/SharedBall";
nc.connect( uri );

The "SharedBall" name in the sample is the corresponding application's name (int the apps folder).

Flex clients can access server messaging configuration information using the ServerConfig class and read the Rtmp channel configuration to determine the endpoint url to connect to.

var nc:NetConnection = new NetConnection();
var uri:String = ServerConfig.getChannel( "my-rtmp" ).endpoint + "/SharedBall";
nc.connect( uri );

Once the application accepts the connection request, the connection is available to both the client (flash.net.NetConnection in AS3) and the server (FluorineFx.Messaging.Api.IConnection).