Beispiel #1
0
        public async Task <T> InvokeAsync <T>(string endpoint, string destination, string method, object[] arguments)
        {
            if (objectEncoding != ObjectEncoding.Amf3)
            {
                throw new NotSupportedException("Flex RPC requires AMF3 encoding.");
            }
            var remotingMessage = new RemotingMessage
            {
                ClientId    = ClientId, //Guid.NewGuid().ToString("D"),
                Destination = destination,
                Operation   = method,
                Body        = arguments,
                Headers     = new AsObject
                {
                    { FlexMessageHeaders.Endpoint, endpoint },
                    { FlexMessageHeaders.FlexClientId, ClientId ?? "nil" },
                    { FlexMessageHeaders.RequestTimeout, 60 }
                }
            };

            var invoke = new InvokeAmf3
            {
                InvokeId   = GetNextInvokeId() + int.MaxValue / 4,
                MethodCall = new Method(null, new object[] { remotingMessage })
            };
            var result = await QueueCommandAsTask(invoke, 3, 0);

            return((T)MiniTypeConverter.ConvertTo(result.Body, typeof(T)));
        }
        public async Task <T> InvokeAsync <T>(string endpoint, string destination, string method, object[] arguments)
        {
            if (objectEncoding != ObjectEncoding.Amf3)
            {
                throw new NotSupportedException("Flex RPC requires AMF3 encoding.");
            }
            var client_id       = Guid.NewGuid().ToString("D");
            var remotingMessage = new RemotingMessage
            {
                ClientId    = client_id,
                Destination = destination,
                Operation   = method,
                Body        = arguments,
                Headers     = new Dictionary <string, object>()
                {
                    { FlexMessageHeaders.Endpoint, endpoint },
                    { FlexMessageHeaders.FlexClientId, client_id ?? "nil" }
                }
            };

            var result = await QueueCommandAsTask(new InvokeAmf3()
            {
                InvokeId   = GetNextInvokeId(),
                MethodCall = new Method(null, new object[] { remotingMessage })
            }, 3, 0);

            return((T)MiniTypeConverter.ConvertTo(result, typeof(T)));
        }
        public async Task <T> InvokeAsync <T>(string method, object[] arguments)
        {
            var result = await QueueCommandAsTask(new InvokeAmf0
            {
                MethodCall = new Method(method, arguments),
                InvokeId   = GetNextInvokeId()
            }, 3, 0);

            return((T)MiniTypeConverter.ConvertTo(result, typeof(T)));
        }
Beispiel #4
0
        internal async Task <T> InvokeAsync <T>(RemotingMessage message)
        {
            var invoke = new InvokeAmf3()
            {
                InvokeId   = GetNextInvokeId(),
                MethodCall = new Method(null, new object[] { message })
            };
            var result = await QueueCommandAsTask(invoke, 3, 0);

            return((T)MiniTypeConverter.ConvertTo(result, typeof(T)));
        }
Beispiel #5
0
        internal async Task <T> InvokeAsync <T>(RemotingMessage message)
        {
            InvokeAmf3 invokeAmf3 = new InvokeAmf3();

            invokeAmf3.InvokeId   = this.GetNextInvokeId();
            invokeAmf3.MethodCall = new Method((string)null, new object[1]
            {
                (object)message
            }, 1 != 0, CallStatus.Request);
            return((T)MiniTypeConverter.ConvertTo((await this.QueueCommandAsTask((Command)invokeAmf3, 3, 0, true)).Body, typeof(T)));
        }
Beispiel #6
0
        public async Task <T> InvokeAsync <T>(string method, object[] arguments)
        {
            InvokeAmf0 invokeAmf0 = new InvokeAmf0();
            Method     method1    = new Method(method, arguments, true, CallStatus.Request);

            invokeAmf0.MethodCall = method1;
            int nextInvokeId = this.GetNextInvokeId();

            invokeAmf0.InvokeId = nextInvokeId;
            return((T)MiniTypeConverter.ConvertTo((await this.QueueCommandAsTask((Command)invokeAmf0, 3, 0, true)).Body, typeof(T)));
        }
            public void SetValue(object instance, object value)
            {
                var targetType = isField ? fieldInfo.FieldType : propertyInfo.PropertyType;
                var val        = MiniTypeConverter.ConvertTo(value, targetType);

                if (isField)
                {
                    fieldInfo.SetValue(instance, val);
                }
                else
                {
                    propertyInfo.SetValue(instance, val);
                }
            }
Beispiel #8
0
        public async Task <T> InvokeAsync <T>(string endpoint, string destination, string method, object[] arguments)
        {
            if (this._objectEncoding != ObjectEncoding.Amf3)
            {
                throw new NotSupportedException("Flex RPC requires AMF3 encoding.");
            }
            RemotingMessage remotingMessage1 = new RemotingMessage();
            string          clientId         = this.ClientId;

            remotingMessage1.ClientId = clientId;
            string str1 = destination;

            remotingMessage1.Destination = str1;
            string str2 = method;

            remotingMessage1.Operation = str2;
            object[] objArray = arguments;
            remotingMessage1.Body    = (object)objArray;
            remotingMessage1.Headers = new AsObject()
            {
                {
                    "DSEndpoint",
                    (object)endpoint
                },
                {
                    "DSId",
                    (object)(this.ClientId ?? "nil")
                },
                {
                    "DSRequestTimeout",
                    (object)60
                }
            };
            RemotingMessage remotingMessage2 = remotingMessage1;
            InvokeAmf3      invokeAmf3       = new InvokeAmf3();

            invokeAmf3.InvokeId   = this.GetNextInvokeId();
            invokeAmf3.MethodCall = new Method((string)null, new object[1]
            {
                remotingMessage2
            }, 1 != 0, CallStatus.Request);
            return((T)MiniTypeConverter.ConvertTo((await this.QueueCommandAsTask(invokeAmf3, 3, 0, true)).Body, typeof(T)));
        }
Beispiel #9
0
 public async Task <T> InvokeAsync <T>(string endpoint, string destination, string method, object[] arguments)
 {
     try
     {
         if (_objectEncoding != ObjectEncoding.Amf3)
         {
             throw new NotSupportedException("Flex RPC requires AMF3 encoding.");
         }
         RemotingMessage remotingMessage = new RemotingMessage()
         {
             ClientId    = ClientId,
             Destination = destination,
             Operation   = method,
             Body        = arguments,
             Headers     = new AsObject()
             {
                 {
                     "DSEndpoint", endpoint
                 },
                 {
                     "DSId", ClientId ?? "nil"
                 },
                 {
                     "DSRequestTimeout", 60
                 }
             }
         };
         InvokeAmf3 invokeAmf3 = new InvokeAmf3()
         {
             InvokeId   = GetNextInvokeId(),
             MethodCall = new Method(null, new object[1] {
                 remotingMessage
             }, 1 != 0, CallStatus.Request)
         };
         return((T)MiniTypeConverter.ConvertTo((await QueueCommandAsTask(invokeAmf3, 3, 0, true)).Body, typeof(T)));
     }
     catch (Exception ex)
     {
         Tools.Log(ex.StackTrace);
         return(default(T));
     }
 }
Beispiel #10
0
        public async Task <T> InvokeAsync <T>(string endpoint, string destination, string method, object[] arguments)
        {
            if (this._objectEncoding != ObjectEncoding.Amf3)
            {
                throw new NotSupportedException("Flex RPC requires AMF3 encoding.");
            }
            RemotingMessage remotingMessage = new RemotingMessage()
            {
                ClientId    = ClientId,
                Destination = destination,
                Operation   = method,
                Body        = arguments,
                Headers     = new AsObject()
                {
                    {
                        "DSEndpoint",
                        (object)endpoint
                    },
                    {
                        "DSId",
                        (object)(this.ClientId ?? "nil")
                    },
                    {
                        "DSRequestTimeout",
                        (object)60
                    }
                }
            };

            InvokeAmf3 invokeAmf = new InvokeAmf3()
            {
                InvokeId   = this.GetNextInvokeId() + 536870911,
                MethodCall = new Method(null, new object[1]
                {
                    remotingMessage
                }, 1 != 0, CallStatus.Request)
            };

            return((T)MiniTypeConverter.ConvertTo((await this.QueueCommandAsTask(invokeAmf, 3, 0, true)).Body, typeof(T)));
        }
Beispiel #11
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     return(MiniTypeConverter.ConvertTo(value, destinationType));
 }