Пример #1
0
        public void Call <T>(string endpoint, string destination, string source, string operation, Responder <T> responder, params object[] arguments)
        {
            if (_netConnection.ObjectEncoding == ObjectEncoding.AMF0)
            {
                throw new NotSupportedException("AMF0 not supported for Flex RPC");
            }
            try {
                TypeHelper._Init();

                RemotingMessage remotingMessage = new RemotingMessage();
                remotingMessage.clientId    = Guid.NewGuid().ToString("D");
                remotingMessage.destination = destination;
                remotingMessage.messageId   = Guid.NewGuid().ToString("D");
                remotingMessage.timestamp   = 0;
                remotingMessage.timeToLive  = 0;
                remotingMessage.SetHeader(MessageBase.EndpointHeader, endpoint);
                remotingMessage.SetHeader(MessageBase.FlexClientIdHeader, _netConnection.ClientId ?? "nil");
                //Service stuff
                remotingMessage.source    = source;
                remotingMessage.operation = operation;
                remotingMessage.body      = arguments;

                FlexInvoke       invoke      = new FlexInvoke();
                PendingCall      pendingCall = new PendingCall(null, new object[] { remotingMessage });
                ResponderHandler handler     = new ResponderHandler(responder);
                pendingCall.RegisterCallback(handler);
                invoke.ServiceCall = pendingCall;
                invoke.InvokeId    = _connection.InvokeId;
                _connection.RegisterPendingCall(invoke.InvokeId, pendingCall);
                Write(invoke);
            } catch (Exception ex) {
                _netConnection.RaiseNetStatus(ex);
            }
        }
Пример #2
0
 public void Call <T>(string command, Responder <T> responder, params object[] arguments)
 {
     try {
         TypeHelper._Init();
         Invoke           invoke      = new Invoke();
         PendingCall      pendingCall = new PendingCall(command, arguments);
         ResponderHandler handler     = new ResponderHandler(responder);
         pendingCall.RegisterCallback(handler);
         invoke.ServiceCall = pendingCall;
         invoke.InvokeId    = _connection.InvokeId;
         _connection.RegisterPendingCall(invoke.InvokeId, pendingCall);
         Write(invoke);
     } catch (Exception ex) {
         _netConnection.RaiseNetStatus(ex);
     }
 }
Пример #3
0
 public void Receive <T>(Responder <T> responder)
 {
     try
     {
         TypeHelper._Init();
         Invoke           invoke      = new Invoke();
         PendingCall      pendingCall = new PendingCall(null, null);
         ResponderHandler handler     = new ResponderHandler(responder);
         pendingCall.RegisterCallback(handler);
         _connection.RegisterPendingReceive(pendingCall);
     }
     catch (Exception ex)
     {
         _netConnection.RaiseNetStatus(ex);
     }
 }
Пример #4
0
        public void Command <T>(string endpoint, string destination, string operation, string subtopic, Responder <T> responder, params object[] arguments)
        {
            if (_netConnection.ObjectEncoding == ObjectEncoding.AMF0)
            {
                throw new NotSupportedException("AMF0 not supported for Flex RPC");
            }

            try
            {
                TypeHelper._Init();

                CommandMessage commandMessage;
                if (operation == "subscribe")
                {
                    commandMessage = new CommandMessage(CommandMessage.SubscribeOperation);
                }
                else
                {
                    commandMessage = new CommandMessage(CommandMessage.UnsubscribeOperation);
                }

                commandMessage.destination = destination;
                commandMessage.clientId    = subtopic;
                commandMessage.messageId   = Guid.NewGuid().ToString("D");
                commandMessage.timestamp   = 0;
                commandMessage.timeToLive  = 0;
                commandMessage.SetHeader(MessageBase.EndpointHeader, endpoint);
                commandMessage.SetHeader(MessageBase.FlexClientIdHeader, _netConnection.ClientId ?? "nil");
                commandMessage.SetHeader(AsyncMessage.SubtopicHeader, subtopic);
                commandMessage.body = arguments;

                //Console.WriteLine("WTF Command Message Endpoint: " + endpoint + " ClientID: " + _netConnection.ClientId);

                FlexInvoke       invoke      = new FlexInvoke();
                PendingCall      pendingCall = new PendingCall(null, new object[] { commandMessage });
                ResponderHandler handler     = new ResponderHandler(responder);
                pendingCall.RegisterCallback(handler);
                invoke.ServiceCall = pendingCall;
                invoke.InvokeId    = _connection.InvokeId;
                _connection.RegisterPendingCall(invoke.InvokeId, pendingCall);
                Write(invoke);

                //Console.WriteLine("CLIENT ID: " + _connection.GetStreamById(0).Connection.Client.Id);

                /*
                 * ChannelDefinition channelDefinition = new ChannelDefinition();
                 * channelDefinition.Class = "flex.messaging.endpoints.";
                 * channelDefinition.Id = "3";
                 *
                 * MessageBroker msgBroker = MessageBroker.GetMessageBroker(null);
                 *
                 * ServicesConfiguration sc = new ServicesConfiguration();
                 * ServiceDefinition serviceDefinition = new ServiceDefinition(sc);
                 *
                 * serviceDefinition.Id = FluorineFx.Messaging.Services.RemotingService.RemotingServiceId;
                 * serviceDefinition.Class = typeof(FluorineFx.Messaging.Services.RemotingService).FullName;
                 * serviceDefinition.MessageTypes = "flex.messaging.messages.AsyncMessage";
                 *
                 * AdapterDefinition def = new AdapterDefinition();
                 * def.Id = "dotnet";
                 * def.Class = typeof(FluorineFx.Messaging.Services.Messaging.MessagingAdapter).FullName;
                 * def.Default = true;
                 * serviceDefinition.AddAdapter(def);
                 * serviceDefinition.Adapters = new AdapterDefinition[] { def };
                 * AdapterRef adapterRef = new AdapterRef();
                 * adapterRef.Ref = "dotnet";
                 *
                 * DestinationDefinition destDefinition = new DestinationDefinition(serviceDefinition);
                 * destDefinition.Id = "messagingDestination";
                 * destDefinition.AdapterRef = adapterRef;
                 * DestinationProperties properties = new DestinationProperties();
                 * properties.Source = "*";
                 * destDefinition.Properties = properties;
                 * serviceDefinition.AddDestination(destDefinition);
                 *
                 * RemotingService remotingService = new RemotingService(msgBroker, serviceDefinition);
                 *
                 * Client myClient = new Client(new ClientManager(msgBroker), _netConnection.ClientId);
                 * _connection.Initialize(myClient);
                 *
                 * MessageClient msgClient = new MessageClient(subtopic, new MessageDestination(remotingService, destDefinition), endpoint);
                 *
                 * MessageServer serv = new MessageServer();
                 * serv.ServicesConfiguration = sc;
                 */
            }
            catch (Exception ex)
            {
                _netConnection.RaiseNetStatus(ex);
            }
        }