Exemplo n.º 1
0
        public static void Products(ServerClient client)
        {
            UserData user = (UserData)client.UserState;

            if (user.Authenticated)
            {
                /**
                 * Get the user's products from the API.
                 */
                new Http(
                    "/products",
                    String.Format("?username={0}", user.Username),
                    (response) =>
                {
                    Helper.Log("[client] {0}: products - {1} - successful", client.EndPoint.ToString(), user.Username);

                    if (response == "%API_ERROR%" || response == "invalid_usage" || response == "unknown_user")
                    {
                        Senders.Error(client, "The server retuned an error.");
                        return;
                    }

                    Senders.Products(client, response);
                });
            }
        }
Exemplo n.º 2
0
        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));
                });
            }
        }