On Monday, November 22, 2021 at 7:09:22 PM UTC-8
meng...@gmail.com wrote:
> I didn't have any hint to locate which connection/fd from this 'tag'. I
> think grpc have some record to pair this 'tag' with connection. And if one
> client send multiple requests, each request has its own 'tag', but grpc
> will find the connection/fd from these tags. So I think I have to find
> this 'tag' - connection map inside grpc. But not find yet. Please correct
> me if i'm wrong.
Ah. You're asking about things like "which client is on the other end of
this call". Look at ServerContext::auth_context [1] and ServerContext::peer
[2]. My memory of exactly how Finish and FinializeResult work together is
hazy. If you no longer have access to the ServerContext when
Finish/FinializeResult is running, you'll need to copy the value you need
from the ServerContext into whatever per-tag data structure you use.
Consider, though, whether you need to be tracking the connection on a "per
socket"/"per fd" level or if you need to be tracking a "connection" at a
higher level, like a single user's "session" in your service. What should
the behavior be in the client device changes networks, like switching from a
cell connection to a WiFi connection? Are those different "connections" or
the same?
[1]:
https://grpc.github.io/grpc/cpp/classgrpc_1_1_server_context.html#a2b28535186cbe2d7b6ed1ff59980191b[2]:
https://grpc.github.io/grpc/cpp/classgrpc_1_1_server_context.html#a6e94cf9e11550b34ab98271202f03adc