public class AppAdapter : MessagingAdapter, ISessionListener { public AppAdapter() { ClientManager.AddSessionCreatedListener(this); } #region ISessionListener Members public void SessionCreated(IClient client) { // client.AddSessionDestroyedListener(this); } public void SessionDestroyed(IClient client) { // } #endregion public override object Invoke(IMessage message) { // return null; } }
[RemotingService()] public class DataService { public DataService() { } // . public string GetData() { return "Hello, world!"; } }
<configuration> <configSections> <sectionGroup name="fluorinefx"> <section name="settings" type="FluorineFx.Configuration.XmlConfigurator, FluorineFx" requirePermission="false"/> </sectionGroup> </configSections> <fluorinefx> <settings> <rtmpServer> <threadpool minWorkerThreads="0" maxWorkerThreads="25" idleTimeout="60000"/> <rtmpConnection pingInterval="0" maxInactivity="60000" maxHandshakeTimeout="0"/> <rtmptConnection pingInterval="5000" maxInactivity="60000" maxHandshakeTimeout="5000"/> <rtmpTransport receiveBufferSize="4096" sendBufferSize="4096" tcpNoDelay="true"/> </rtmpServer> </settings> </fluorinefx> <system.web> <compilation debug="true" targetFramework="4.0" /> <httpModules> <add name="FluorineGateway" type="FluorineFx.FluorineGateway,FluorineFx" /> </httpModules> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules runAllManagedModulesForAllRequests="true"> <add name="FluorineGateway" type="FluorineFx.FluorineGateway, FluorineFx"/> </modules> </system.webServer> </configuration>
<?xml version="1.0" encoding="utf-8" ?> <services-config> <services> <service-include file-path="remoting-config.xml" /> <service-include file-path="messaging-config.xml" /> </services> <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}:1950" class="flex.messaging.endpoints.RTMPEndpoint"/> </channel-definition> </channels> </services-config>
<fx:Declarations> <mx:Consumer id="consumer" destination="data_destination" message="messageHandler(event)"/> <mx:RemoteObject id="dataRO" destination="DataDest"> <mx:method name="GetData" result="GetDataResult(event)" fault="GetDataFault(event)" /> </mx:RemoteObject> </fx:Declarations> <fx:Script> <![CDATA[ private function GetDataResult(event:ResultEvent):void { var result:String = event.result as String; // } private function GetDataFault(event:FaultEvent):void{ var error:String = ObjectUtil.toString(event.fault); // } private function messageHandler(event:MessageEvent):void { var msg:IMessage = event.message; var type:object = msg.body; // } ]]> </fx:Script>
public class AppAdapter : MessagingAdapter, ISessionListener { /* * ... */ public override object Invoke(IMessage message) { // MessageService messageService = this.Destination.Service as MessageService; messageService.PushMessageToClients(message); return null; } public static void SendMessage(string message) { MessageBroker msgBroker = MessageBroker.GetMessageBroker(null); AsyncMessage msg = new AsyncMessage(); msg.destination = "data_destination"; msg.headers.Add(AsyncMessage.SubtopicHeader, "client"); msg.headers.Add(AsyncMessage.EndpointHeader, "my-rtmp"); msg.headers.Add(AsyncMessage.RemoteCredentialsHeader, string.Empty); msg.headers.Add(AsyncMessage.FlexClientIdHeader, Guid.NewGuid().ToString("D")); msg.clientId = Guid.NewGuid().ToString("D"); msg.messageId = Guid.NewGuid().ToString("D"); msg.timestamp = Environment.TickCount; msg.body = message; msgBroker.RouteMessage(msg); } }
Source: https://habr.com/ru/post/128001/
All Articles