internal ConnectMessageEventArgs(string clientId, string authToken, CommandMessage message, string endpoint, string dsId, int invokeId, AsObject cParameters) : base(message, endpoint, dsId, invokeId) { this.ClientId = clientId; this.AuthToken = authToken; this.ConnectionParameters = cParameters; }
public async Task <AcknowledgeMessageExt> ReconnectAckAsync(int invokeId, AsObject cParameters, params object[] parameters) { return(new AcknowledgeMessageExt { Body = await ReconnectAsync(invokeId, cParameters, parameters) }); }
void WriteAsObject(AsObject value) { CheckDebug.NotNull(value); ReferenceAdd(value); if (string.IsNullOrEmpty(value.TypeName)) { WriteMarker(Marker.Object); } else { WriteMarker(Marker.TypedObject); b.WriteUtfPrefixed(value.TypeName); } foreach (var property in value) { b.WriteUtfPrefixed(property.Key); WriteItem(property.Value); } // object end is marked with a zero-length field name, and an end of object marker. b.WriteUInt16(0); WriteMarker(Marker.ObjectEnd); }
private AsObject BuildAsync(object body) { AsObject obj = new AsObject(); obj.Add("Body", body); return(obj); }
internal ConnectMessageEventArgs(string clientId, string authToken, CommandMessage message, string endpoint, string dsId, int invokeId, AsObject cParameters) : base(message, endpoint, dsId, invokeId) { ClientId = clientId; AuthToken = authToken; ConnectionParameters = cParameters; }
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; }
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> ReconnectAckAsync(int invokeId, AsObject cParameters, params object[] parameters) { AcknowledgeMessageExt acknowledgeMessageExt1 = new AcknowledgeMessageExt(); AcknowledgeMessageExt acknowledgeMessageExt2 = acknowledgeMessageExt1; AsObject asObject = await this.ReconnectAsync(invokeId, cParameters, parameters); acknowledgeMessageExt2.Body = (object)asObject; return(acknowledgeMessageExt1); }
public async Task <AcknowledgeMessageExt> ReconnectAckAsync() { AcknowledgeMessageExt acknowledgeMessageExt1 = new AcknowledgeMessageExt(); AcknowledgeMessageExt acknowledgeMessageExt2 = acknowledgeMessageExt1; AsObject asObject = await this.ReconnectAsync(); acknowledgeMessageExt2.Body = (object)asObject; return(acknowledgeMessageExt1); }
public async Task <AsObject> ReconnectAsync(int invokeId, AsObject cParameters, params object[] parameters) { var client = CreateTcpClient(); client.NoDelay = NoDelay; client.ReceiveTimeout = ReceiveTimeout; client.SendTimeout = SendTimeout; client.ExclusiveAddressUse = ExclusiveAddressUse; await client.ConnectAsync(uri.Host, uri.Port); var stream = await GetRtmpStreamAsync(client); var random = new Random(); var randomBytes = new byte[1528]; random.NextBytes(randomBytes); // write c0+c1 var c01 = new RtmpHandshake { Version = 3, Time = (uint)Environment.TickCount, Time2 = 0, Random = randomBytes }; await RtmpHandshake.WriteAsync(stream, c01, true); // read s0+s1 var s01 = await RtmpHandshake.ReadAsync(stream, true); // write c2 var c2 = s01.Clone(); c2.Time2 = (uint)Environment.TickCount; await RtmpHandshake.WriteAsync(stream, c2, false); // read s2 var s2 = await RtmpHandshake.ReadAsync(stream, false); // handshake check. won't work if running a local server (time will be the same) so run on debug #if !DEBUG if (!c01.Random.SequenceEqual(s2.Random) || c01.Time != s2.Time) { throw new ProtocolViolationException(); } #endif EstablishThreads(stream); var connectResult = await ConnectInvokeAsync(invokeId, cParameters, parameters); hasConnected = true; IsDisconnected = false; return(connectResult); }
public virtual void testLiteralObject2() { Object obj = AsObject.createLiteralObject("a", "This is string", "b", 10); String a = (String)(((AsObject)(obj)).getOwnProperty("a")); int b = (int)(((AsObject)(obj)).getOwnProperty("b")); ((AsObject)(obj)).setOwnProperty("a", a); ((AsObject)(obj)).setOwnProperty("b", b); }
AsObject ReadAsObject() { var asObject = new AsObject(); refs.Add(asObject); asObject.Replace(ReadItems()); return(asObject); }
private AsObject BuildError(string destination, string operation, object[] args, object response) { AsObject obj = new AsObject(); obj.Add("Destination", destination); obj.Add("Operation", operation); obj.Add("Arguments", args); obj.Add("Return", response); return obj; }
private AsObject BuildError(string destination, string operation, object[] args, object response) { AsObject obj = new AsObject(); obj.Add("Destination", destination); obj.Add("Operation", operation); obj.Add("Arguments", args); obj.Add("Return", response); return(obj); }
public ClassDescription GetClassDescription(object obj) { AsObject source = (AsObject)obj; if (!source.IsTyped) { return(AsObjectWrapper.EmptyClassDescription); } IMemberWrapper[] array = source.Select <KeyValuePair <string, object>, IMemberWrapper>((Func <KeyValuePair <string, object>, IMemberWrapper>)(x => (IMemberWrapper) new AsObjectWrapper.AsObjectMemberWrapper(x.Key))).ToArray <IMemberWrapper>(); return((ClassDescription) new AsObjectWrapper.AsObjectClassDescription(this._serializationContext.GetAlias(source.TypeName), array, false, false)); }
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 <AsObject> ConnectAsync() { TcpClient client = this.CreateTcpClient(); client.NoDelay = this.NoDelay; client.ReceiveTimeout = this.ReceiveTimeout; client.SendTimeout = this.SendTimeout; client.ExclusiveAddressUse = this.ExclusiveAddressUse; await client.ConnectAsync(this._uri.Host, this._uri.Port); Stream stream = await this.GetRtmpStreamAsync(client); Random random = new Random(); byte[] numArray = new byte[1528]; byte[] buffer = numArray; random.NextBytes(buffer); RtmpHandshake c01 = new RtmpHandshake() { Version = 3, Time = (uint)Environment.TickCount, Time2 = 0, Random = numArray }; await RtmpHandshake.WriteAsync(stream, c01, true); RtmpHandshake h = (await RtmpHandshake.ReadAsync(stream, true)).Clone(); h.Time2 = (uint)Environment.TickCount; await RtmpHandshake.WriteAsync(stream, h, false); RtmpHandshake rtmpHandshake = await RtmpHandshake.ReadAsync(stream, false); if (!((IEnumerable <byte>)c01.Random).SequenceEqual <byte>((IEnumerable <byte>)rtmpHandshake.Random) || (int)c01.Time != (int)rtmpHandshake.Time) { throw new ProtocolViolationException(); } this.EstablishThreads(stream); AsObject asObject = await this.ConnectInvokeAsync((string)null, (string)null, this._uri.ToString()); string key1 = "clientId"; object obj; if (asObject.TryGetValue(key1, out obj)) { this.ClientId = obj as string; } string key2 = "id"; if (asObject.TryGetValue(key2, out obj)) { this.ClientId = this.ClientId ?? obj as string; } return(asObject); }
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); }
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); }
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)); }
public virtual void load(AsURLRequest request) { mRequest = request; String url = request.getUrl(); if (url.StartsWith("http")) { throw new NotImplementedException("Http loading not implemented"); } data = BcResFactory.GetInstance().LoadResource(url); AsDebug.assert(data != null, url); dispatchEvent(new AsEvent(AsEvent.COMPLETE)); }
protected bool Equals(IField other) { if (AsObject == null) { return(other.AsObject == null); } if (other.AsObject == null) { return(AsObject == null); } return(AsObject.Equals(other.AsObject) || other.AsObject.Equals(AsObject) || AsObject.GetHashCode() == other.AsObject.GetHashCode()); }
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)); }
AsObject ConvertToAsObject(Dictionary <string, object> dict) { var asobj = new AsObject(); foreach (var el in dict as Dictionary <string, object> ) { if (el.Key == "TypeName") { asobj.TypeName = el.Value as string; } else { asobj[el.Key] = el.Value is Dictionary <string, object>?ConvertToAsObject(el.Value as Dictionary <string, object>) : el.Value; } } return(asobj); }
void HandleConnectInvokeAsync(Command command) { string code; string description; bool connect_result = false; var app = ((AsObject)command.ConnectionParameters)["app"]; if (app == null) { OnDisconnected(new ExceptionalEventArgs("app value cannot be null")); return; } this.app = app.ToString(); if (!server.AuthApp(app.ToString(), ClientId)) { code = "NetConnection.Connect.Error"; description = "Connection Failure."; } else { code = "NetConnection.Connect.Success"; description = "Connection succeeded."; connect_result = true; } connectTime = DateTime.UtcNow; AsObject param = new AsObject { { "code", code }, { "description", description }, { "level", "status" }, }; ReturnResultInvoke(new AsObject { { "capabilities", 255.00 }, { "fmsVer", "FMS/4,5,1,484" }, { "mode", 1.0 } }, command.InvokeId, param, false, connect_result); if (!connect_result) { OnDisconnected(new ExceptionalEventArgs("Auth Failure")); return; } }
public static PromoteItem LeaguesPromote(string json) { var newItem = new PromoteItem(); var serializer = new JavaScriptSerializer(); var deserializedJson = serializer.Deserialize<Dictionary<string, object>>(json); var leagueItem = deserializedJson["leagueItem"] as Dictionary<string, object>; if (leagueItem == null) return newItem; var asd = new AsObject(); newItem.notifyReason = deserializedJson["notifyReason"] as string; newItem.LeaguePointsDelta = deserializedJson["leaguePointsDelta"] as int?; newItem.LeaguePointsDelta = deserializedJson["gameId"] as int?; foreach (var item in leagueItem) { asd.Add(item.Key,item.Value); } newItem.leagueItem = (LeagueItemDTO)(object)asd; return newItem; }
public async Task <AsObject> ReconnectAsync(int invokeId, AsObject cParameters, params object[] parameters) { TcpClient client = this.CreateTcpClient(); client.NoDelay = this.NoDelay; client.ReceiveTimeout = this.ReceiveTimeout; client.SendTimeout = this.SendTimeout; client.ExclusiveAddressUse = this.ExclusiveAddressUse; await client.ConnectAsync(this._uri.Host, this._uri.Port); Stream stream = await this.GetRtmpStreamAsync(client); Random random = new Random(); byte[] numArray = new byte[1528]; byte[] buffer = numArray; random.NextBytes(buffer); RtmpHandshake c01 = new RtmpHandshake() { Version = 3, Time = (uint)Environment.TickCount, Time2 = 0, Random = numArray }; await RtmpHandshake.WriteAsync(stream, c01, true); RtmpHandshake h = (await RtmpHandshake.ReadAsync(stream, true)).Clone(); h.Time2 = (uint)Environment.TickCount; await RtmpHandshake.WriteAsync(stream, h, false); RtmpHandshake rtmpHandshake = await RtmpHandshake.ReadAsync(stream, false); if (!((IEnumerable <byte>)c01.Random).SequenceEqual <byte>((IEnumerable <byte>)rtmpHandshake.Random) || (int)c01.Time != (int)rtmpHandshake.Time) { throw new ProtocolViolationException(); } this.EstablishThreads(stream); AsObject asObject = await this.ConnectInvokeAsync(invokeId, cParameters, parameters); this.IsDisconnected = false; return(asObject); }
public static PromoteItem LeaguesPromote(string json) { var newItem = new PromoteItem(); var serializer = new JavaScriptSerializer(); var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(json); var leagueItem = deserializedJson["leagueItem"] as Dictionary <string, object>; if (leagueItem == null) { return(newItem); } var asd = new AsObject(); newItem.notifyReason = deserializedJson["notifyReason"] as string; newItem.LeaguePointsDelta = deserializedJson["leaguePointsDelta"] as int?; newItem.LeaguePointsDelta = deserializedJson["gameId"] as int?; foreach (var item in leagueItem) { asd.Add(item.Key, item.Value); } newItem.leagueItem = (LeagueItemDTO)(object)asd; return(newItem); }
public virtual void advanceTime(float passedTime) { int i = 0; int touchID = 0; AsTouch touch = null; mElapsedTime = mElapsedTime + passedTime; if (mLastTaps.getLength() > 0) { for (i = (int)(mLastTaps.getLength() - 1); i >= 0; --i) { if (mElapsedTime - mLastTaps[i].getTimestamp() > MULTITAP_TIME) { mLastTaps.splice(i, (uint)(1)); } } } while (mQueue.getLength() > 0) { sProcessedTouchIDs.setLength(sHoveringTouchData.setLength(0)); AsVector <AsTouch> __touchs_ = mCurrentTouches; if (__touchs_ != null) { foreach (AsTouch touch in __touchs_) { if (touch.getPhase() == AsTouchPhase.BEGAN || touch.getPhase() == AsTouchPhase.MOVED) { touch.setPhase(AsTouchPhase.STATIONARY); } } } while (mQueue.getLength() > 0 && sProcessedTouchIDs.indexOf(mQueue[mQueue.getLength() - 1][0]) == -1) { AsArray touchArgs = mQueue.pop(); touch = getCurrentTouch(touchID); if (touch != null && touch.getPhase() == AsTouchPhase.HOVER && touch.getTarget() != null) { sHoveringTouchData.push((As_AS_REST)(AsObject.createLiteralObject("touch", touch, "target", touch.getTarget()))); } this.(int)(touchArgs[0]), (String)(touchArgs[1]), (float)(touchArgs[2]), (float)(touchArgs[3]), (float)(touchArgs[4]), (float)(touchArgs[5]), (float)(touchArgs[6]); sProcessedTouchIDs.push(touchID); } AsTouchEvent touchEvent = new AsTouchEvent(AsTouchEvent.TOUCH, mCurrentTouches, mShiftDown, mCtrlDown); AsVector <Object> __touchDatas_ = sHoveringTouchData; if (__touchDatas_ != null) { foreach (Object touchData in __touchDatas_) { if (((AsObject)(((AsObject)(touchData)).getOwnProperty("touch"))).getOwnProperty("target") != ((AsObject)(touchData)).getOwnProperty("target")) { touchEvent.dispatch(getBubbleChain((AsDisplayObject)(((AsObject)(touchData)).getOwnProperty("target")), sBubbleChain)); } } } AsVector <int> __touchIDs_ = sProcessedTouchIDs; if (__touchIDs_ != null) { foreach (int touchID in __touchIDs_) { getCurrentTouch(touchID).dispatchEvent(touchEvent); } } for (i = (int)(mCurrentTouches.getLength() - 1); i >= 0; --i) { if (mCurrentTouches[i].getPhase() == AsTouchPhase.ENDED) { mCurrentTouches.splice(i, (uint)(1)); } } } sBubbleChain.setLength(0); }
private void EnteredQueue(SearchingForMatchNotification result) { if (result.PlayerJoinFailures != null) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { var leaver = result.PlayerJoinFailures[0]; if (leaver.ReasonFailed == "LEAVER_BUSTED") { var x = (BustedLeaver)leaver; Client.Log("LeaverBuster, Access token is: " + x.AccessToken); var message = new MessageOverlay { MessageTitle = { Content = "LeaverBuster" }, MessageTextBox = { Text = "" } }; Timer t = new Timer { Interval = 1000 }; var timeleft = x.LeaverPenaltyMilisRemaining; t.Elapsed += (messafge, mx) => { timeleft = timeleft - 1000; TimeSpan time = TimeSpan.FromMilliseconds(timeleft); Dispatcher.BeginInvoke( DispatcherPriority.Input, new ThreadStart(async() => { //Can not bypass this sadly, it just relaunches message.MessageTextBox.Text = @"Abandoning a match or being AFK results in a negative experience for your teammates, and is a punishable offense in League of Legends. You've been placed in a lower priority queue" + Environment.NewLine; message.MessageTextBox.Text += "You have " + string.Format( "{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again" + Environment.NewLine; message.MessageTextBox.Text += "You can close this window and you will still be in queue"; Client.OverlayContainer.Content = message.Content; if (timeleft < 0) { t.Stop(); Client.OverlayContainer.Visibility = Visibility.Hidden; var obj = new AsObject { { "LEAVER_BUSTER_ACCESS_TOKEN", x.AccessToken } }; EnteredQueue(await RiotCalls.AttachToQueue(param, obj)); } })); }; t.Start(); Client.OverlayContainer.Content = message.Content; Client.OverlayContainer.Visibility = Visibility.Visible; } else { Button item = LastSender; var settings = (QueueButtonConfig)LastSender.Tag; var config = settings.GameQueueConfig; Queues.Remove(config.Id); var failure = result.PlayerJoinFailures[0]; var message = new MessageOverlay { MessageTitle = { Content = "Failed to join queue" }, MessageTextBox = { Text = failure.ReasonFailed } }; switch (failure.ReasonFailed) { case "QUEUE_DODGER": { message.MessageTextBox.Text = "Unable to join the queue due to you recently dodging a game." + Environment.NewLine; TimeSpan time = TimeSpan.FromMilliseconds(failure.PenaltyRemainingTime); message.MessageTextBox.Text = "You have " + string.Format( "{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again"; } break; case "RANKED_MIN_LEVEL": message.MessageTextBox.Text = "You do not meet the requirements for this queue." + Environment.NewLine; break; case "QUEUE_PARTICIPANTS": message.MessageTextBox.Text = "This queue is in dev. Please use this queue on the real league of legends client." + Environment.NewLine; break; } Client.OverlayContainer.Content = message.Content; Client.OverlayContainer.Visibility = Visibility.Visible; } })); } else if (result.JoinedQueues != null) { Button item = new Button(); Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { item = LastSender; var fakeButton = new Button { Tag = item }; item.Content = "00:00"; })); if (t.Enabled) { t.Stop(); } t = new Timer { Interval = 1000 }; t.Start(); time = 0; t.Elapsed += (gg, easy) => { time = time + 1000; TimeSpan timespan = TimeSpan.FromMilliseconds(time); Dispatcher.BeginInvoke( DispatcherPriority.Input, new ThreadStart(() => item.Content = string.Format("{0:D2}m:{1:D2}s", timespan.Minutes, timespan.Seconds))); }; InQueue = true; Client.GameStatus = "inQueue"; Client.timeStampSince = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalMilliseconds; Client.SetChatHover(); Client.RiotConnection.MessageReceived += GotQueuePop; Client.Log("Now in Queue"); } }
AsObject ConvertToAsObject(Dictionary<string, object> dict) { var asobj = new AsObject(); foreach (var el in dict as Dictionary<string, object>) if (el.Key == "TypeName") asobj.TypeName = el.Value as string; else asobj[el.Key] = el.Value is Dictionary<string, object>? ConvertToAsObject(el.Value as Dictionary<string,object>):el.Value; return asobj; }
private AsObject BuildAsync(object body) { AsObject obj = new AsObject(); obj.Add("Body", body); return obj; }
public async Task <bool> ConnectAndLogin() { if (_useGarena) { //this.RaiseError("Garena servers are not yet supported.", ErrorType.Connect); //return false; } SetDefaultsParams(); RtmpClient = new RtmpClient(new Uri(_gameServer), SerializationContext, ObjectEncoding.Amf3); // ISSUE: reference to a compiler-generated field RtmpClient.MessageReceived += OnMessageReceived; LoginQueue loginQueue = new LoginQueue(Username, Password, Region); loginQueue.OnAuthFailed += message => RaiseError(message, ErrorType.Login); loginQueue.OnUpdateStatusMessage += (sender, s) => { if (OnUpdateStatusMessage == null) { return; } object sender1 = sender; string e = s; OnUpdateStatusMessage(sender1, e); }; if (!await loginQueue.GetAuthToken().ConfigureAwait(false)) { return(false); } this.AuthToken = loginQueue.AuthToken; this.UserId = loginQueue.UserId; Stopwatch sw = new Stopwatch(); sw.Start(); try { while (sw.ElapsedMilliseconds / 1000L <= ConnectTimeoutSeconds) { try { AsObject asObject = await RtmpClient.ConnectAsync().ConfigureAwait(false); sw.Stop(); goto label_13; } catch (Exception ex) { Tools.Log(ex.StackTrace); } await Task.Delay(5000).ConfigureAwait(false); continue; label_13: OnConnect?.Invoke((object)this, EventArgs.Empty); this.RtmpClient.SetChunkSize(int.MaxValue); AuthenticationCredentials cred = new AuthenticationCredentials() { Username = Username, Password = Password, ClientVersion = ClientVersion, Domain = "lolclient.lol.riotgames.com", Locale = _locale, OperatingSystem = "Windows 10", AuthToken = AuthToken }; if (_useGarena) { cred.PartnerCredentials = loginQueue.Token; cred.Username = loginQueue.User;//UserId cred.Password = null; } this.Session = await this.Login(cred).ConfigureAwait(false); string[] strArray = new string[3] { "gn", "cn", "bc" }; for (int index = 0; index < strArray.Length; ++index) { strArray[index] = string.Format("{0}-{1}", strArray[index], Session.AccountSummary.AccountId); } bool[] flagArray = await Task.WhenAll(new Task <bool>[3] { RtmpClient.SubscribeAsync("my-rtmps", "messagingDestination", strArray[0], strArray[0]), RtmpClient.SubscribeAsync("my-rtmps", "messagingDestination", strArray[1], strArray[1]), RtmpClient.SubscribeAsync("my-rtmps", "messagingDestination", "bc", strArray[2]) }).ConfigureAwait(false); if (_useGarena) { IsConnected = await RtmpClient.LoginAsync(cred.Username, Session.Token).ConfigureAwait(false); } else { IsConnected = await RtmpClient.LoginAsync(Username.ToLower(), Session.Token).ConfigureAwait(false); } //IsConnected = await RtmpClient.LoginAsync(Username.ToLower(), Session.Token).ConfigureAwait(false); _heartbeatTimer = new Timer(); _heartbeatTimer.Elapsed += new ElapsedEventHandler(DoHeartBeat); _heartbeatTimer.Interval = 120000.0; _heartbeatTimer.Start(); _uptime = DateTime.Now; OnLogin?.Invoke(Username); return(true); } sw.Stop(); RaiseError("Connection failed.", ErrorType.Connect); return(false); } catch (InvocationException ex) { if (ex.RootCause != null && ex.RootCause.GetType() == typeof(LoginFailedException)) { LoginFailedException rootCause = (LoginFailedException)ex.RootCause; string errorCode = rootCause.ErrorCode; if (!(errorCode == "LOGIN-0018")) { if (errorCode == "LOGIN-0019") { RaiseError("User blocked.", ErrorType.Login); return(false); } this.RaiseError(string.Format("{0}: {1}", "LoginFailedException", rootCause.ErrorCode).Trim(), ErrorType.Login); return(false); } RaiseError("Password change required.", ErrorType.Password); return(false); } if (!string.IsNullOrEmpty(ex.Message)) { RaiseError(ex.Message, ErrorType.Invoke); return(false); } } catch (Exception ex) { Tools.Log(ex.StackTrace); } finally { sw.Stop(); } this.RaiseError("Login failed with unknown error. Try again later.", ErrorType.Login); return(false); }
private async void EventReceivedCallback(object sender, EventReceivedEventArgs e) { try { Command command; object param; switch (e.Event.MessageType) { case MessageType.UserControlMessage: UserControlMessage userControlMessage = (UserControlMessage)e.Event; if (userControlMessage.EventType == UserControlMessageType.PingRequest) { this.WriteProtocolControlMessage((RtmpEvent) new UserControlMessage(UserControlMessageType.PingResponse, userControlMessage.Values)); break; } break; case MessageType.CommandAmf3: case MessageType.DataAmf0: case MessageType.CommandAmf0: command = (Command)e.Event; Method methodCall = command.MethodCall; param = methodCall.Parameters.Length == 1 ? methodCall.Parameters[0] : (object)methodCall.Parameters; if (methodCall.Name == "_result" || methodCall.Name == "_error" || methodCall.Name == "receive") { throw new InvalidDataException(); } if (!(methodCall.Name == "onstatus")) { if (methodCall.Name == "connect") { CommandMessage parameter = (CommandMessage)methodCall.Parameters[3]; object obj1; parameter.Headers.TryGetValue("DSEndpoint", out obj1); object obj2; parameter.Headers.TryGetValue("DSId", out obj2); ConnectMessageEventArgs args = new ConnectMessageEventArgs((string)methodCall.Parameters[1], (string)methodCall.Parameters[2], parameter, (string)obj1, (string)obj2, command.InvokeId, (AsObject)command.ConnectionParameters); // ISSUE: reference to a compiler-generated field EventHandler <ConnectMessageEventArgs> connectMessageReceived = this.ConnectMessageReceived; if (connectMessageReceived != null) { ConnectMessageEventArgs e1 = args; connectMessageReceived((object)this, e1); } if (parameter.Operation == CommandOperation.ClientPing) { AsObject asObject1 = await this.InvokeConnectResultAsync(command.InvokeId, (AsObject)args.Result.Body); } else { AsObject asObject2 = await this.InvokeReconnectResultInvokeAsync(command.InvokeId, (AsObject)args.Result.Body); } args = (ConnectMessageEventArgs)null; break; } if (param is RemotingMessage) { RemotingMessage message = param as RemotingMessage; object obj1; message.Headers.TryGetValue("DSEndpoint", out obj1); object obj2; message.Headers.TryGetValue("DSId", out obj2); string endpoint = (string)obj1; string clientId = (string)obj2; int invokeId = command.InvokeId; RemotingMessageReceivedEventArgs receivedEventArgs = new RemotingMessageReceivedEventArgs(message, endpoint, clientId, invokeId); // ISSUE: reference to a compiler-generated field EventHandler <RemotingMessageReceivedEventArgs> remotingMessageReceived = this.RemotingMessageReceived; if (remotingMessageReceived != null) { RemotingMessageReceivedEventArgs e1 = receivedEventArgs; remotingMessageReceived((object)this, e1); } if (receivedEventArgs.Error == null) { this.InvokeResult(command.InvokeId, receivedEventArgs.Result); break; } this.InvokeError(command.InvokeId, receivedEventArgs.Error); break; } if (param is CommandMessage) { CommandMessage message = param as CommandMessage; object obj1; message.Headers.TryGetValue("DSEndpoint", out obj1); object obj2; message.Headers.TryGetValue("DSId", out obj2); string endpoint = obj1 as string; string dsId = obj2 as string; int invokeId = command.InvokeId; CommandMessageReceivedEventArgs receivedEventArgs = new CommandMessageReceivedEventArgs(message, endpoint, dsId, invokeId); // ISSUE: reference to a compiler-generated field EventHandler <CommandMessageReceivedEventArgs> commandMessageReceived = this.CommandMessageReceived; if (commandMessageReceived != null) { CommandMessageReceivedEventArgs e1 = receivedEventArgs; commandMessageReceived((object)this, e1); } this.InvokeResult(command.InvokeId, receivedEventArgs.Result); break; } break; } break; } command = (Command)null; param = (object)null; } catch (ClientDisconnectedException ex) { } }
private void EnteredQueue(SearchingForMatchNotification result) { if (result.PlayerJoinFailures != null) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { var leaver = result.PlayerJoinFailures[0]; if (leaver.ReasonFailed == "LEAVER_BUSTED") { var x = (BustedLeaver)leaver; Client.Log("LeaverBuster, Access token is: " + x.AccessToken); var message = new MessageOverlay { MessageTitle = { Content = "LeaverBuster" }, MessageTextBox = { Text = "" } }; Timer t = new Timer { Interval = 1000 }; var timeleft = x.LeaverPenaltyMilisRemaining; t.Elapsed += (messafge, mx) => { timeleft = timeleft - 1000; TimeSpan time = TimeSpan.FromMilliseconds(timeleft); Dispatcher.BeginInvoke( DispatcherPriority.Input, new ThreadStart(async() => { //Can not bypass this sadly, it just relaunches message.MessageTextBox.Text = @"Abandoning a match or being AFK results in a negative experience for your teammates, and is a punishable offense in League of Legends. You've been placed in a lower priority queue" + Environment.NewLine; message.MessageTextBox.Text += "You have " + string.Format( "{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again" + Environment.NewLine; message.MessageTextBox.Text += "You can close this window and you will still be in queue"; Client.OverlayContainer.Content = message.Content; if (timeleft < 0) { t.Stop(); Client.OverlayContainer.Visibility = Visibility.Hidden; var obj = new AsObject { { "LEAVER_BUSTER_ACCESS_TOKEN", x.AccessToken } }; EnteredQueue(await RiotCalls.AttachToQueue(param, obj)); } })); }; t.Start(); Client.OverlayContainer.Content = message.Content; Client.OverlayContainer.Visibility = Visibility.Visible; } else { Button item = LastSender; var settings = (QueueButtonConfig) LastSender.Tag; var config = settings.GameQueueConfig; Queues.Remove(config.Id); var failure = result.PlayerJoinFailures[0]; var message = new MessageOverlay { MessageTitle = { Content = "Failed to join queue" }, MessageTextBox = { Text = failure.ReasonFailed } }; switch (failure.ReasonFailed) { case "QUEUE_DODGER": { message.MessageTextBox.Text = "Unable to join the queue due to you recently dodging a game." + Environment.NewLine; TimeSpan time = TimeSpan.FromMilliseconds(failure.PenaltyRemainingTime); message.MessageTextBox.Text = "You have " + string.Format( "{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again"; } break; case "RANKED_MIN_LEVEL": message.MessageTextBox.Text = "You do not meet the requirements for this queue." + Environment.NewLine; break; case "QUEUE_PARTICIPANTS": message.MessageTextBox.Text = "This queue is in dev. Please use this queue on the real league of legends client." + Environment.NewLine; break; } Client.OverlayContainer.Content = message.Content; Client.OverlayContainer.Visibility = Visibility.Visible; } })); } else if (result.JoinedQueues != null) { Button item = new Button(); Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { item = LastSender; var fakeButton = new Button { Tag = item }; item.Content = "00:00"; })); if (t.Enabled) t.Stop(); t = new Timer { Interval = 1000 }; t.Start(); time = 0; t.Elapsed += (gg, easy) => { time = time + 1000; TimeSpan timespan = TimeSpan.FromMilliseconds(time); Dispatcher.BeginInvoke( DispatcherPriority.Input, new ThreadStart(() => item.Content = string.Format("{0:D2}m:{1:D2}s", timespan.Minutes, timespan.Seconds))); }; InQueue = true; Client.GameStatus = "inQueue"; Client.timeStampSince = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalMilliseconds; Client.SetChatHover(); Client.RiotConnection.MessageReceived += GotQueuePop; Client.Log("Now in Queue"); } }
public virtual void writeObject(AsObject _object) { throw new AsNotImplementedError(); }
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); }