I'm making a videogame and I need clients and server to communicate (in Unity).
The message from the server needs to be converted to a specific type based on the request: for example, the registration process will return just a bool in case of success or not; the login process must return a lot of information in a dictionary for the user who logged in (level, experience, game progress, etc.)
In java I used to do something like this:
net().post(url.toString(), safeUrl, new Callback<String>()
{
public void onFailure(Throwable t)
{
// do something to handle the failure...
}
public void onSuccess(String json)
{
// do something...
}
});
Basically the net().post was sending a post http request to the server, and once it was done the server was calling the correct method.
I read that C# can't do this, but that delegates can achieve something similar, do you know how? so basically I just send to the post request a method as parameter and handle it? Also is it possible to use generic types to handle the different types of requests?
Or Is there a better way to do this?