❔ Web Question
Hi guys,
I need a little advice on which software technique to choose....
The situation is that I have a frontend that needs to fetch data from an ASP.NET backend.
This data it should fetch is on a game server, I can write extensions to connect to it, but it is not uncommon that e.g. a user has multiple servers, so when he clicks on something in the frontend it should be applied to all his servers. But data should also be requested which I then simply receive back which then goes back into the frontend via the rest endpoint.
Now I'm wondering if SignalR is the right decision, because I come to the point that if I get the data via SignalR I don't know how to return it via the rest endpoint.
And if I use GRPC I don't know how to get only the channels from a specific client to ask for the exact data return requests.
Maybe someone has an idea and there are some techniques I haven't considered yet.
37 Replies
Hi,
Assign UUID on instantiation for each client's channel, Register it at backend after page loaded(mapping all open channels' UUIDs from that single client).
Thanks for that answer, I was thinking about something similar but how do I get the channel from the client ?
Does the clients opens the channel and sends it back to the backend?
I need to understand what sort of application you are working on.
Assuming it's a web app (or website):- As soon as the page renders (initialize/mounted hook) you can send a request to backend to create UUID (at backend) and send it to front-end to be saved in local storage so left/next of the page can be served on that channel(assuming channel here means a different device/node where also the same client's logged in web app is running).
if client clear local storage (cached UUID) from a channel (device) then you can rotate the same UUID session with client a until all of them are occupied where you can create new one (after all of them are occupied and it's less than some minutes or hours that a new device is used by same client
or better get the device info from borwser and Map UUID(s) like that if you are allowed to collect that data (instead of above method).
If i am assuming channel and the type of app not in the right manner please do let know.
Instead of starting with GRPC or SignlR connection why not start with RPC or REST to first differentiate between the devices and then serve to user with the type of connection you want to have.
If course,
First of all it’s an api, so just rest requests.
The asp net backend (rest api) needs to collect data from a game server.
So I wanted to use Grpc or signalR for the communication between the game servers and the backend.
Means if 10 people have a game server, 10 game server clients are connected to my backend… so I can communicate bidirectional, because if someone requests data from the game server with a special query, I need to answer this request with the data found on the game server.
I thought it’s a good idea but I’m happy to find a better idea how to communicate with the game server.
Rest -> game server -> backend -> rest
So it’s like a question and answer
sounds good 👍
Yeah but there is the problem 😂
I don’t know how to manage the question answer with the incoming test request
If I use grpc i can call the method with my parameters and just receive an answer, that would be great.
But I only want to send it to the game server it belongs to
So that’s why I need to register all the clients some how at the backend so if someone makes a request I need to figure out if the game server is already connected
So, let me be clear on this. You have 10 game servers, and a backend.
A user comes. The user interacts with game server and you want your backend to respond to it ?
10 is just a number
I have multiple customers but its like 1:n so every customer can have multiple Game but they will be linked together so its fine if they all get the same data 😄
The Backend needs to sort out now the grpc clients and group them by the customerId, so if a customer makes a request, i can figure out which gameserver (grpc client) belongs to him to call the methods
The User makes a web request with his authentication and so on.
Through that i know the customer id
When the game server starts it needs to log on to the backend as well with authentication so i know which server belongs to which customer.
So i can sort it.
So A customer makes a request to the backend web api for example post request to /data
Body:
Now i want to call a method on the associated grpc client (Game Server) so i can get back the data
This is what i want to return to the customer via the rest api
So what i have to figure out is how to handle this stuff with grpc
Handle connection management automatically.
Sends messages to all connected clients simultaneously.
Sends messages to specific clients or groups of clients.
So it's n:n relationship not 1:n because many clients can have many game servers joined
ok i think i got it
Yep 😄 sorry for the mistake 😄
There is one more thing, Since it's n:n i think you have already managed that for a generic method request to figure out which game server the client is calling first.
So the client request for info from game server
then backend find out which game server the client is referring to
and retrieve info on behalf of client from that server and deliver it to the client
Correct
So my main problem is probably the connection between the gameserver and the backend...
I am still not sure as to what other factors are you considering as an issue if client can (should if the client have joined more than once) choose which game server to get info from ?
No only one game server could join once
The game server are syncing it self, so if i request it for example from one out of 10 its basically the same data like from the other 9
I see
It's a distributed system
not separate system 😄
right ?
like game servers
they are all synced just distributed to handle load
Yeah correct 😄
got you
and if a customer doesnt want it synced he creates a new account to link the other server 😄
In my head is still, im not sure if gRPC the best choice or if there is something else...
I see, So it's like partial management of load where there are separate servers that do not sync
There is one more thing, If all servers are synced and some are not That means client is managed as per the client's choice (Either to get into a distributed cluster that syncs (A), or to join up another server that doesn't(B)).
If client joins A, In the end for each new connection created the client will be using the synced data right ?
And if joined B well then you can have a DB entry to directly create connection of client with B.
And as soon as connection ends just sync all servers. Won't that work ?
At the end, i dont care what about the game server syncing 😄
Im not sure how to communicate with the game server to get the data... so i can return it via rest
May i ask are you self hosting those servers or i can see them in public ?
which the game servers ?
No the customers own the server and just install the plugin i write 😄
ah ok
Yep 😄
So its basically a minecraft server which the customer owns, and they drop a plugin inside, and configure the backend URL and the authentication in a config of them
and now the minecraft server connects to my backend
so i need to communicate with it
So this is basically what im trying to do 😄
But the Communication between the Minecraft Plugin
You said you tried to communitcate with it through signlR but you are not sure how to return the fetched info back to the user who requested it, So you are able to get info by singlR from game server that part works with it, right ?
Should work i mean its a java client which connects to the C# backend
but if the signalR hub receives a message, then its in the hub and cannot be used as rest response
I don't think that could be an issue
I mean why can't you handle Http backend while also handle SignalR ?
have route & in the controller manage SignalR
https://www.youtube.com/watch?v=_gJ0NbNKKZg take a look at this as well
Nick Proud
YouTube
Create Your Own Chat App: SignalR Mastery in C# & ASP.NET
#dotnet #csharp #tutorial #softwaredevelopment #signalR #aspdotnetcore #programming #softwareengineer #softwareengineering #softwareengineeringtutorials
Updating a UI from new data in a SQL or NoSQL database is costly in terms of performance. What if when data came into your API or was typed into a web form, it immediately updated another mic...
just gave me some idea of how both of the things can be done under single request (can be applied in backend)
Any timestamp where hes trying that ? 😄
Otherwise i will watch it in full probably better anyway
i will see what i can do thank you very much ^^
Your welcome
no time stamp
try from here
it's js
for front-end
but if you can manage it in node js
the
connection
buildingIm still curious how i give back a json respons from the hub but he will describe it probably 😄
yes you will get the idea. I got plenty after watching him and also use chatGPT and maybe you can conduct whole thing in c#
e.g. 👆
after event listened on js client
you can manage the routes from there and just use it simply with single line function as Proud (guy in vid) did
you will find i am sure 😄
best wishes
Thank you very much ^^
really nice thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.