private static void OnDisconnect(DisconnectionInfo info) { Console.WriteLine( $"---- Disconnection happened. ----\n" + $"Reason: {info.CloseStatus}\n" + $"Message: {info.CloseStatusDescription}\n" + $"Subprotocol: {info.SubProtocol}\n" + $"Exception: {info.Exception}\n" + $"---------------------------------"); if (success) { info.CancelReconnection = true; } else if (info.Exception != null) { info.CancelReconnection = true; SSOEventArgs e = new SSOEventArgs(); e.Exception = info.Exception; e.success = false; if (SSOFinished != null) { SSOFinished(null, e); } } }
private static void OnSSOLogin(object sender, SSOEventArgs e) { /*if (e.success) * { * User.APIKey = e.APIKey; * User.Save(); * }*/ }
private static void OnMessage(ResponseMessage msg) { if (msg.MessageType == System.Net.WebSockets.WebSocketMessageType.Text) { JObject response = JObject.Parse(msg.Text); if (response["success"].Value <bool>()) { JObject data = (JObject)response["data"]; if (data.ContainsKey("connection_token")) { connectionToken = data["connection_token"].ToString(); Utils.OpenURL("https://www.nexusmods.com/sso?id=" + uuidv4 + "&application=" + NexusMods.ApplicationSlug); } if (data.ContainsKey("api_key")) { success = true; SSOEventArgs e = new SSOEventArgs(); e.APIKey = data["api_key"].ToString(); e.success = true; if (SSOFinished != null) { SSOFinished(null, e); } } } else { Console.WriteLine($"Something went wrong: {response["error"]}"); } } else { Console.WriteLine($"Received message was not of type 'Text': {msg}"); return; } }