public static void Load(ServerClient client, string product) { UserData user = (UserData)client.UserState; if (user.Authenticated) { /** * Get the .dll from the API. */ new Http( "/load", String.Format("?username={0}&product={1}", user.Username, product), (response) => { Helper.Log("[client] {0}: load - {1} / {2} - successful", client.EndPoint.ToString(), user.Username, product); if (response == "%API_ERROR%" || response == "invalid_usage" || response == "unknown_product") { Senders.Error(client, "The server retuned an error."); return; } if (response == "no_access") { Senders.Error(client, "You don't have access to this product."); return; } if (response == "dll_not_present") { Senders.Error(client, "Product is currently not available."); return; } Senders.Load(client, Convert.FromBase64String(response)); }); } }
public static void Authentication(ServerClient client, string username, string password, string hwid) { /** * Call the API. */ new Http( "/authentication", String.Format("?username={0}&password={1}&hwid={2}", username, password, Helper.Base64EncodeUrl(hwid)), (response) => { Helper.Log("[client] {0}: auth: {1}", client.EndPoint.ToString(), response); switch (response) { case "%API_ERROR%": Senders.Authentication(client, AuthResponse.ServerError); break; case "unknown_user": Senders.Authentication(client, AuthResponse.UnknownUser); break; case "invalid_password": Senders.Authentication(client, AuthResponse.InvalidPassword); break; case "invalid_hwid": Senders.Authentication(client, AuthResponse.InvalidHwid); break; case "user_unverified": Senders.Authentication(client, AuthResponse.Unverified); break; case "user_banned": Senders.Authentication(client, AuthResponse.Banned); break; case "success": /** * Get the user's rank. */ new Http("/rank", "?username=" + username, (string rank) => { /** * Setup the user data. */ UserData user = (UserData)client.UserState; user.Username = username; user.Password = password; user.Hwid = hwid; user.Rank = rank; user.Authenticated = true; Senders.Authentication(client, AuthResponse.Success, user.Username, user.Rank); }); break; default: break; } }); }