Ejemplo n.º 1
0
        public async Task <AsObject> ConnectResultInvokeAsync(object[] parameters)
        {
            //Write ServerBW & ClientBW
            var ServerBW = new WindowAcknowledgementSize(245248000);

            WriteProtocolControlMessage(ServerBW);
            var ClientBW = new PeerBandwidth(250000, 2);

            WriteProtocolControlMessage(ClientBW);

            SetChunkSize(50000);
            ClientId = Uuid.NewUuid();
            var connectResult = new InvokeAmf0
            {
                MethodCall = new Method("_result", new object[1] {
                    new AsObject
                    {
                        { "objectEncoding", 3.0 },
                        { "level", "status" },
                        { "details", null },
                        { "description", "Connection succeeded." },
                        { "DSMessagingVersion", 1.0 },
                        { "code", "NetConnection.Connect.Success" },
                        { "id", Uuid.NewUuid() }
                    }
                }),
                InvokeId = GetNextInvokeId()
            };

            return((AsObject) await QueueCommandAsTask(connectResult, 3, 0));
        }
Ejemplo n.º 2
0
        public async Task <AsObject> InvokeConnectResultAsync(int invokeId, AsObject param)
        {
            //Write ServerBW & ClientBW
            var ServerBW = new WindowAcknowledgementSize(245248000);

            WriteProtocolControlMessage(ServerBW);
            var ClientBW = new PeerBandwidth(250000, 2);

            WriteProtocolControlMessage(ClientBW);

            SetChunkSize(50000);
            var connectResult = new InvokeAmf0
            {
                MethodCall = new Method("_result", new[] { param }),
                InvokeId   = invokeId
            };

            return((AsObject) await QueueCommandAsTask(connectResult, 3, 0));
        }
Ejemplo n.º 3
0
        private byte[] GetMessageBytes(RtmpHeader header, RtmpEvent message)
        {
            switch (header.MessageType)
            {
            case MessageType.SetChunkSize:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) => w.WriteInt32(((ChunkSize)o).Size))));

            case MessageType.AbortMessage:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) => w.WriteInt32(((Abort)o).StreamId))));

            case MessageType.Acknowledgement:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) => w.WriteInt32(((Acknowledgement)o).BytesRead))));

            case MessageType.UserControlMessage:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) =>
                {
                    UserControlMessage userControlMessage = (UserControlMessage)o;
                    w.WriteUInt16((ushort)userControlMessage.EventType);
                    foreach (int num in userControlMessage.Values)
                    {
                        w.WriteInt32(num);
                    }
                })));

            case MessageType.WindowAcknowledgementSize:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) => w.WriteInt32(((WindowAcknowledgementSize)o).Count))));

            case MessageType.SetPeerBandwidth:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) =>
                {
                    PeerBandwidth peerBandwidth = (PeerBandwidth)o;
                    w.WriteInt32(peerBandwidth.AcknowledgementWindowSize);
                    w.WriteByte((byte)peerBandwidth.LimitType);
                })));

            case MessageType.Audio:
            case MessageType.Video:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) => w.WriteBytes(((ByteData)o).Data))));

            case MessageType.DataAmf3:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) => this.WriteData(w, o, ObjectEncoding.Amf3))));

            case MessageType.SharedObjectAmf3:
                return(new byte[0]);

            case MessageType.CommandAmf3:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) =>
                {
                    w.WriteByte((byte)0);
                    this.WriteCommandOrData(w, o, ObjectEncoding.Amf3);
                })));

            case MessageType.DataAmf0:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) => this.WriteData(w, o, ObjectEncoding.Amf0))));

            case MessageType.SharedObjectAmf0:
                return(new byte[0]);

            case MessageType.CommandAmf0:
                return(this.GetMessageBytes(message, (Action <AmfWriter, RtmpEvent>)((w, o) => this.WriteCommandOrData(w, o, ObjectEncoding.Amf0))));

            case MessageType.Aggregate:
                Debugger.Break();
                return(new byte[0]);

            default:
                throw new ArgumentOutOfRangeException("Unknown RTMP message type: " + (object)(int)header.MessageType);
            }
        }