async Task <AsObject> ConnectInvokeAsync(string pageUrl, string swfUrl, Uri tcUrl) { string app = null; var segments = tcUrl.AbsolutePath.Split('/'); if (segments.Length >= 2) { app = segments[1]; } var connect = new InvokeAmf0 { MethodCall = new Method("connect", new object[0]), ConnectionParameters = new AsObject { { "pageUrl", pageUrl }, { "objectEncoding", (double)objectEncoding }, { "capabilities", 15 }, { "audioCodecs", 1639 }, { "flashVer", "WIN 9,0,115,0" }, { "swfUrl", swfUrl }, { "videoFunction", 1 }, { "fpad", false }, { "videoCodecs", 252 }, { "tcUrl", tcUrl }, { "app", app } }, InvokeId = GetNextInvokeId() }; return((AsObject) await QueueCommandAsTask(connect, 3, 0, requireConnected : false)); }
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)); }
void HandlePublish(Command command) { string path = (string)command.MethodCall.Parameters[0]; if (!server.RegisterPublish(app, path, ClientId)) { OnDisconnected(new ExceptionalEventArgs("Server publish error")); return; } var status = new AsObject { { "level", "status" }, { "code", "NetStream.Publish.Start" }, { "description", "Stream is now published." }, { "details", path } }; var call_on_status = new InvokeAmf0 { MethodCall = new Method("onStatus", new object[] { status }), InvokeId = 0, ConnectionParameters = null, }; call_on_status.MethodCall.CallStatus = CallStatus.Request; call_on_status.MethodCall.IsSuccess = true; // result.MessageType = MessageType.UserControlMessage; var stream_begin = new UserControlMessage(UserControlMessageType.StreamBegin, new int[] { StreamId }); WriteProtocolControlMessage(stream_begin); writer.Queue(call_on_status, StreamId, random.Next()); SetResultValInvoke(new object(), command.InvokeId); IsPublishing = true; }
public async Task <AsObject> PlayInvokeAsync() { var connect = new InvokeAmf0 { MethodCall = new Method("play", new object[] { streamName, -2, -1, false }), // ConnectionParameters = new AsObject // { // { "pageUrl", pageUrl }, // { "objectEncoding", (double)objectEncoding }, // { "capabilities", 15 }, // { "audioCodecs", 1639 }, // { "flashVer", "WIN 9,0,115,0" }, // { "swfUrl", swfUrl }, // { "videoFunction", 1 }, // { "fpad", false }, // { "videoCodecs", 252 }, // { "tcUrl", tcUrl }, // { "app", appName } // }, InvokeId = GetNextInvokeId() }; return((AsObject) await QueueCommandAsTask(connect, 3 /*8*/ /*3*/, 0, requireConnected : false)); }
private void HandlePlay(Command command) { string path = (string)command.MethodCall.Parameters[0]; if (!server.RegisterPlay(app, path, ClientId)) { OnDisconnected(new ExceptionalEventArgs("play parameter auth failed")); return; } WriteProtocolControlMessage(new UserControlMessage(UserControlMessageType.StreamIsRecorded, new int[] { StreamId })); WriteProtocolControlMessage(new UserControlMessage(UserControlMessageType.StreamBegin, new int[] { StreamId })); var status_reset = new AsObject { { "level", "status" }, { "code", "NetStream.Play.Reset" }, { "description", "Resetting and playing stream." }, { "details", path } }; var call_on_status_reset = new InvokeAmf0 { MethodCall = new Method("onStatus", new object[] { status_reset }), InvokeId = 0, ConnectionParameters = null, }; call_on_status_reset.MethodCall.CallStatus = CallStatus.Request; call_on_status_reset.MethodCall.IsSuccess = true; var status_start = new AsObject { { "level", "status" }, { "code", "NetStream.Play.Start" }, { "description", "Started playing." }, { "details", path } }; var call_on_status_start = new InvokeAmf0 { MethodCall = new Method("onStatus", new object[] { status_start }), InvokeId = 0, ConnectionParameters = null, }; call_on_status_start.MethodCall.CallStatus = CallStatus.Request; call_on_status_start.MethodCall.IsSuccess = true; writer.Queue(call_on_status_reset, StreamId, random.Next()); writer.Queue(call_on_status_start, StreamId, random.Next()); try { server.SendMetadata(app, path, this); server.ConnectToClient(app, path, ClientId, ChannelType.Video); server.ConnectToClient(app, path, ClientId, ChannelType.Audio); } catch (Exception e) { OnDisconnected(new ExceptionalEventArgs("Not Found", e)); } IsPlaying = true; }
public async Task <AcknowledgeMessageExt> InvokeAckAsync(int invokeId, string method, CommandMessage arg) { InvokeAmf0 invokeAmf0 = new InvokeAmf0(); invokeAmf0.MethodCall = new Method(method, new object[1] { (object)arg }, 1 != 0, CallStatus.Request); invokeAmf0.InvokeId = invokeId; return(await this.QueueCommandAsTask((Command)invokeAmf0, 3, 0, true)); }
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 async Task <T> InvokeAsync <T>(string method, object[] arguments) { var invoke = new InvokeAmf0 { MethodCall = new Method(method, arguments), InvokeId = GetNextInvokeId() }; var result = await QueueCommandAsTask(invoke, 3, 0); return((T)MiniTypeConverter.ConvertTo(result, typeof(T))); }
public async Task <double> CreateStreamInvokeAsync() { var connect = new InvokeAmf0 { MethodCall = new Method("createStream", new object[] { }), InvokeId = GetNextInvokeId() }; return((double) await QueueCommandAsTask(connect, 3, 0, requireConnected : false)); // return await InvokeAsync<AsObject>("") }
public async Task <AsObject> InvokeReconnectResultInvokeAsync(int invokeId, AsObject param) { this.SetChunkSize(50000); InvokeAmf0 invokeAmf0 = new InvokeAmf0(); invokeAmf0.MethodCall = new Method("_result", new object[1] { (object)param }, 1 != 0, CallStatus.Request); invokeAmf0.InvokeId = invokeId; return((AsObject)await this.QueueCommandAsTask((Command)invokeAmf0, 3, 0)); }
public async Task <AcknowledgeMessageExt> InvokeAckAsync(int invokeId, string method, CommandMessage arg) { //TODO: this is very bad //this.invokeId = invokeId; var invoke = new InvokeAmf0 { MethodCall = new Method(method, new object[] { arg }), InvokeId = invokeId }; return(await QueueCommandAsTask(invoke, 3, 0)); }
private async Task <AsObject> ConnectInvokeAsync(int invokeId, AsObject connectionParameters, params object[] parameters) { InvokeAmf0 invokeAmf0 = new InvokeAmf0(); Method method = new Method("connect", parameters, true, CallStatus.Request); invokeAmf0.MethodCall = method; AsObject asObject = connectionParameters; invokeAmf0.ConnectionParameters = (object)asObject; int num = invokeId; invokeAmf0.InvokeId = num; return((AsObject)(await this.QueueCommandAsTask((Command)invokeAmf0, 3, 0, false)).Body); }
public async Task <AsObject> InvokeConnectResultAsync(int invokeId, AsObject param) { this.WriteProtocolControlMessage((RtmpEvent) new WindowAcknowledgementSize(245248000)); this.WriteProtocolControlMessage((RtmpEvent) new PeerBandwidth(250000, (byte)2)); this.SetChunkSize(50000); InvokeAmf0 invokeAmf0 = new InvokeAmf0(); invokeAmf0.MethodCall = new Method("_result", new object[1] { (object)param }, 1 != 0, CallStatus.Request); invokeAmf0.InvokeId = invokeId; return((AsObject)await this.QueueCommandAsTask((Command)invokeAmf0, 3, 0)); }
private async Task <AsObject> ConnectInvokeAsync(int invokeId, AsObject connectionParameters, params object[] parameters) { var connect = new InvokeAmf0 { MethodCall = new Method("connect", parameters), ConnectionParameters = connectionParameters, InvokeId = invokeId }; var result = (AsObject)(await QueueCommandAsTask(connect, 3, 0, false)).Body; return(result); }
void ReturnResultInvoke(object connectParameters, int transcationId, object param, bool requiredConnected = true, bool success = true) { var result = new InvokeAmf0 { MethodCall = new Method("_result", new object[] { param }), InvokeId = transcationId, ConnectionParameters = connectParameters }; result.MethodCall.CallStatus = CallStatus.Result; result.MethodCall.IsSuccess = success; writer.Queue(result, StreamId, random.Next()); Console.WriteLine("_result"); }
public async Task <AsObject> InvokeReconnectResultInvokeAsync(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)); }
public async Task <AsObject> ConnectResultInvokeAsync(object[] parameters) { this.WriteProtocolControlMessage((RtmpEvent) new WindowAcknowledgementSize(245248000)); this.WriteProtocolControlMessage((RtmpEvent) new PeerBandwidth(250000, (byte)2)); this.SetChunkSize(50000); InvokeAmf0 invokeAmf0 = new InvokeAmf0(); invokeAmf0.MethodCall = new Method("_result", new object[1] { (object)new AsObject() { { "objectEncoding", (object)3.0 }, { "level", (object)"status" }, { "details", (object)null }, { "description", (object)"Connection succeeded." }, { "DSMessagingVersion", (object)1.0 }, { "code", (object)"NetConnection.Connect.Success" }, { "id", (object)Uuid.NewUuid() } } }, 1 != 0, CallStatus.Request); invokeAmf0.InvokeId = this.GetNextInvokeId(); return((AsObject)await this.QueueCommandAsTask((Command)invokeAmf0, 3, 0)); }
private async Task <AsObject> ConnectInvokeAsync(string pageUrl, string swfUrl, string tcUrl) { var connect = new InvokeAmf0 { MethodCall = new Method("connect", new object[] { false, "nil", "", new CommandMessage { Operation = (CommandOperation)5, CorrelationId = "", MessageId = Uuid.NewUuid(), Destination = "", Headers = new AsObject { { FlexMessageHeaders.FlexMessagingVersion, 1.0 }, { FlexMessageHeaders.FlexClientId, "my-rtmps" } } } }), ConnectionParameters = new AsObject { { "pageUrl", pageUrl }, { "objectEncoding", (double)_objectEncoding }, { "capabilities", 239.0 }, { "audioCodecs", 3575.0 }, { "flashVer", "WIN 11,7,700,169" }, { "swfUrl", swfUrl }, { "videoFunction", 1.0 }, { "fpad", false }, { "videoCodecs", 252.0 }, { "tcUrl", tcUrl }, { "app", "" } }, InvokeId = GetNextInvokeId() }; var result = (AsObject)(await QueueCommandAsTask(connect, 3, 0, false)).Body; return(result); }
async Task <AsObject> ReconnectInvokeAsync(string pageUrl, string swfUrl, string tcUrl, string token) { var connect = new InvokeAmf0 { MethodCall = new Method("connect", new object[] { false, ClientId, token, new CommandMessage { Operation = CommandOperation.Login, CorrelationId = "", MessageId = Uuid.NewUuid(), Destination = "", Body = token, Headers = new AsObject { { FlexMessageHeaders.FlexMessagingVersion, 1.0 }, { FlexMessageHeaders.FlexClientId, "my-rtmps" }, } } }), ConnectionParameters = new AsObject { { "pageUrl", pageUrl }, { "objectEncoding", (double)objectEncoding }, { "capabilities", 239.0 }, { "audioCodecs", 3575.0 }, { "flashVer", "WIN 16,0,0,228" }, { "swfUrl", "app:/LolClient.swf/[[DYNAMIC]]/47" }, { "videoFunction", 1.0 }, { "fpad", false }, { "videoCodecs", 252.0 }, { "tcUrl", tcUrl }, { "app", "" } }, InvokeId = GetNextInvokeId() }; return((AsObject) await QueueCommandAsTask(connect, 3, 0, requireConnected : false)); }
async Task <AsObject> ConnectInvokeAsync(string pageUrl, string swfUrl, string tcUrl) { var connect = new InvokeAmf0 { MethodCall = new Method("connect", new object[0]), ConnectionParameters = new AsObject { { "pageUrl", pageUrl }, { "objectEncoding", (double)objectEncoding }, { "capabilities", 15 }, { "audioCodecs", 1639 }, { "flashVer", "WIN 9,0,115,0" }, { "swfUrl", swfUrl }, { "videoFunction", 1 }, { "fpad", false }, { "videoCodecs", 252 }, { "tcUrl", tcUrl }, { "app", null } }, InvokeId = GetNextInvokeId() }; return((AsObject) await QueueCommandAsTask(connect, 3, 0, requireConnected : false)); }
private async Task <AcknowledgeMessageExt> ReconnectInvokeAckAsync(string pageUrl, string swfUrl, string tcUrl) { InvokeAmf0 invokeAmf0_1 = new InvokeAmf0(); InvokeAmf0 invokeAmf0_2 = invokeAmf0_1; string methodName = "connect"; object[] parameters = new object[4] { (object)false, (object)this.ClientId, (object)this._reconnectData, null }; int index = 3; CommandMessage commandMessage = new CommandMessage(); commandMessage.Operation = CommandOperation.Login; string str1 = ""; commandMessage.CorrelationId = str1; string str2 = Uuid.NewUuid(); commandMessage.MessageId = str2; string str3 = ""; commandMessage.Destination = str3; string reconnectData = this._reconnectData; commandMessage.Body = (object)reconnectData; commandMessage.Headers = new AsObject() { { "DSMessagingVersion", (object)1.0 }, { "DSId", (object)"my-rtmps" } }; parameters[index] = (object)commandMessage; int num1 = 1; int num2 = 0; Method method = new Method(methodName, parameters, num1 != 0, (CallStatus)num2); invokeAmf0_2.MethodCall = method; invokeAmf0_1.ConnectionParameters = (object)new AsObject() { { "pageUrl", (object)pageUrl }, { "objectEncoding", (object)(double)this._objectEncoding }, { "capabilities", (object)239.0 }, { "audioCodecs", (object)3575.0 }, { "flashVer", (object)"WIN 11,7,700,169" }, { "swfUrl", (object)swfUrl }, { "videoFunction", (object)1.0 }, { "fpad", (object)false }, { "videoCodecs", (object)252.0 }, { "tcUrl", (object)tcUrl }, { "app", (object)"" } }; invokeAmf0_1.InvokeId = this.GetNextInvokeId(); return(await this.QueueCommandAsTask((Command)invokeAmf0_1, 3, 0, false)); }