internal void InvokeError(int invokeId, ErrorMessage message)
        {
            if (objectEncoding != ObjectEncoding.Amf3)
                throw new NotSupportedException("Flex RPC requires AMF3 encoding.");

            var invoke = new InvokeAmf3()
            {
                InvokeId = invokeId,
                MethodCall = new Method("_error", new object[] { message }, false, CallStatus.Result)
            };
            QueueCommandAsTask(invoke, 3, 0);
        }
        internal void InvokeReceive(string clientId, string subtopic, object body)
        {

            var invoke = new InvokeAmf3()
            {
                InvokeId = 0,
                MethodCall = new Method("receive", new object[] 
                { 
                    new AsyncMessageExt
                    {
                        Headers=new AsObject{{FlexMessageHeaders.FlexSubtopic, subtopic}},
                        ClientId=clientId,
                        Body=body,
                        MessageId=Uuid.NewUuid()
                    }
                })
            };
            QueueCommandAsTask(invoke, 3, 0);
        }
        internal void InvokeResult(int invokeId, AcknowledgeMessageExt message)
        {
            if (objectEncoding != ObjectEncoding.Amf3)
                throw new NotSupportedException("Flex RPC requires AMF3 encoding.");

            var invoke = new InvokeAmf3()
            {
                InvokeId = invokeId,
                MethodCall = new Method("_result", new object[] { message }, true, CallStatus.Result)
            };
            QueueCommandAsTask(invoke, 3, 0);
        }