I'm a beginner and recently tried to get started with FireSharp, and even got some data transfered:
This was my first Code to send data to the server:
public static class Client { static IFirebaseClient client; static IFirebaseConfig config = new FirebaseConfig { AuthSecret = "MyAuthSecret", BasePath = "MyBasePath" }; public static bool Start() { client = new FirebaseClient(config); if (client != null) { return true; } else { return false; } } public static void Send(Data data) { SetResponse response = await client.SetAsync("Testpath", data); }
But at the line SetResponse response = await client.SetAsync("Testpath", data);
, I got the following error message:
The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.
I was still able to send data, simply by reducing the line to client.SetAsync("Testpath", data);
. I knew it wasn't ideal, since I didn't got a response that way, but it worked!
The real problem was, that I didn't managed to come up with such a workaround for FirebaseResponse response = await client.GetAsync("Testpath");
. That way I'm currently unable to get data from the server.
Does anyone have any idea on what the problem could be or how to fix it?
My ideas were:
- Maybe it has something to do with the fact that I put all this in a static class.
- Maybe the FireSharp Libary is broken in the current version.
- Maybe I could manually mark the methods as async, since thats whats the error-message saying.
- Or I could manually change it's return type, as the error-message says.
- Maybe I understood the whole
"await"
and"async"
thing wrong.- The manual says,
"FirebaseClient uses Newtonsoft.Json by default.
Maybe that could have anything to do with it.
But I havent tried any of them, since I don't know how. I have no idea whether it is possible and would make sence to change the code of the libary, or whatever the error-message means with "change the return type"
. I watched a tutorial and looked at the manual, but couldn't find any information about this problem.
I would really appreciate any help since I wasn't able to find any information about this problem on the Internet so far.