Как заставить wpf подключаться к firebase через прокси - PullRequest
0 голосов
/ 08 октября 2019

Мне было поручено создать приложение для обмена сообщениями в wpf. Мы достигли этого, используя fiirebase в качестве нашей базы данных и используя пакет слепков firesharp для подключения к firebase. Вот пример кода, который подключается к firebase, а также как вставить что-то в firebase

 public class Firebase
{
    static string basePath = Properties.Settings.Default.FirebaseAppUri;
    static string storagePath = Properties.Settings.Default.FirebaseStorage;

    //Setup Firebase path and access rights
    IFirebaseConfig config = new FirebaseConfig
    {
        AuthSecret = Properties.Settings.Default.NormalFireKey,
        BasePath = basePath
    };

    IFirebaseClient client;

    public Firebase()
    {
        //Connect to the Firebase database
        client = new FireSharp.FirebaseClient(config);

        //If the client can't connect to the DB, notify the user
        if (client == null)
        {
            MessageBox.Show("You are currently offline, please reconnect to the internet in order to continue using Brood.NET.",
                            "No internet access",
                            MessageBoxButton.OK,
                            MessageBoxImage.Error);
        }
    }

    //Insert an object into the database
    //Storage location is the full file path of the object, except for the object's name

    public async void Insert(string storageLocation, object dataObject)
    {
        try
        {
            SetResponse response = await client.SetTaskAsync(storageLocation, dataObject);
        }
        catch (Exception e)
        {
            MessageBox.Show(e.Message);
        }
    }      

    //Retrieve an object from the database
    //Storage location is the full file path of the object, except for the object's name
    public async Task<List<Message>> GetMessages(string storageLocation, string dataObjectName)
    {
        try
        {
            FirebaseResponse response = await client.GetTaskAsync($"{storageLocation}/{dataObjectName}");
            List<Message> messages = response.ResultAs<List<Message>>();
            return messages;
        }
        catch (Exception e)
        {
            //MessageBox.Show(e.Message);
            return null;
        }
    }

Теперь мой лектор также сказал, что наше приложение должно работать через прокси-сервер, поэтому он сказал, что предоставит нам действительные учетные данные и недействительные учетные данные, а наша программа должна работать только с действительными учетными данными. Как мне реализовать это в нашей программе?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...