Hi there, I’ve been trying to figure out the best way to exchange information between a client-side and a server-side resource. It often happens (at least in my case) that I need to request a server-side information from the client.
However, I haven’t found an optimal way to do this. The only thing I could think of is triggering a server-side event from the client, and then triggering a client-side event from the server as a response. It would still be much better if there was a more efficient method, but I’m not sure if it’s possible.
Something like this (ideally speaking):
string information = AFunctionThatRetrievesInformationsFromServer(args);
For now I have this:
(I use C# for the examples, but I accept any kind of replies)
ClientMain.cs
TriggerServerEvent("anEvent", somedata);
Eventhandlers["theReply"] += new Action<string>((data) => { Debug.WriteLine(data); })
ServerMain.cs
Eventhandlers["anEvent"] = new Action<Player, string>(AFunction);
...
internal void AFunction([FromSource]Player player, string data)
{
TriggerClientEvent(player, "theReply", data);
}
Thanks in advance.