How to make wpf connect to firebase via a Proxy

半世苍凉 提交于 2020-02-06 07:24:53

问题


I have been tasked with creating a messenger app in wpf. We havee accomplished this by using fiirebase as our database and using the firesharp nugget package to connect to firebase, Here is an example of some of the code to connect to firebase as well as how to insert something into 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;
        }
    }

Now my lecturer also said that our application must be able to work through a proxy, thus he said he will give us valid credentials and invalid credentials and our program must only function on valid credentials. How would i mgo about implementing this into our program?

来源:https://stackoverflow.com/questions/58284619/how-to-make-wpf-connect-to-firebase-via-a-proxy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!