philippseith / signalr

SignalR server and client in go
MIT License
133 stars 39 forks source link

[feature/display_remoteaddr] adding remoteaddr information #124

Closed SeniuuS closed 2 years ago

SeniuuS commented 2 years ago

I had a use case where I needed to get remoteaddr (IP) of the clients so I added it to the hub as a getter like the connectionid

philippseith commented 2 years ago

These are pretty massive changes for a very specific use case. What about adding a method to your specific hub where clients can pass their IP address?

SeniuuS commented 2 years ago

Yes I do agree with you, but I also think it would be great for the server/hub to have access to the address of its clients without having the client to do anything.

philippseith commented 2 years ago

Which protocol will the hub use to access the client? ftp? tftp? http? Bare http or https or websocket over https? Just a tcp socket? This will lead to a very specific hub implementation for this additional backward channel. What if the client is not reachable by an IP address?

The hub can access its clients with h.Clients().Client(clientId).Send(target, args...) over the existing connection. A connection might not have an address. For example the PipeConnection is just an object in memory, based on an io.Pipe. You might argue that the address string could be interpreted as memory address, but there you have it: You will need a connection factory which interprets the address string. But a connection between client and hub has already been created: The one the hub was invoked by the client. Why not use this connection to access the client from the hub?

SeniuuS commented 2 years ago

It is through websocket. I had a usecase where I needed the IP of the clients for logging purposes. But no problem, it was just a suggestion to store the address corresponding the connection.