示例#1
0
        void ServerCommandReceived(object sender, CommandMessageReceivedEventArgs e)
        {
            RtmpClient client = (RtmpClient)sender;
            switch (e.Message.Operation)
            {
                case CommandOperation.Login:
                    AcknowledgeMessageExt login = new AcknowledgeMessageExt
                    {
                        Body = "success",
                        CorrelationId = e.Message.MessageId,
                        MessageId = Uuid.NewUuid(),
                        ClientId = Uuid.NewUuid(),
                        Headers = new AsObject
                        {
                            { "DSMessagingVersion", 1.0 },
                            { FlexMessageHeaders.FlexClientId, e.DSId }
                        }
                    };

                    client.InvokeResult(e.InvokeId, login);
                    break;
                case CommandOperation.Subscribe:
                    AcknowledgeMessageExt subscribe = new AcknowledgeMessageExt
                    {
                        Body = null,
                        CorrelationId = e.Message.MessageId,
                        MessageId = Uuid.NewUuid(),
                        ClientId = e.Message.ClientId
                    };

                    client.InvokeResult(e.InvokeId, subscribe);
                    break;
                case CommandOperation.Unsubscribe:
                    break;
                case CommandOperation.ClientPing:
                    break;
                case CommandOperation.Logout:
                    break;
                default:
                    throw new NotSupportedException();
            }

            if (ClientCommandReceieved != null)
            {
                ClientCommandReceieved(sender, e);
            }
        }
        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);
        }