Open bdovaz opened 1 year ago
At the moment I have solved it with reflection, I don't like it but unless there is a public way to access it, I have no choice....
# Get the instance
IMyService myService = null;
object interceptingCallInvoker = myService.GetType()
.GetProperty("CallInvoker", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(myService);
object httpClientCallInvoker = interceptingCallInvoker.GetType()
.GetField("invoker", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(interceptingCallInvoker);
GrpcChannel grpcChannel = httpClientCallInvoker.GetType()
.GetProperty("Channel", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(httpClientCallInvoker) as GrpcChannel;
grpcChannel.Dispose();
Ok. I propose I add a new interface, IGrpcClient or IGrpcClientProxy or something (naming is hard) that exposes the underlying channel etc; all our clients will then implement that - sound workable?
IGrpcClientProxy sounds redundant, no? Client or Proxy, but not both
@mgravell sounds great! Thanks!
@menaheme "naming is hard" :)
That and the halting problem
@mgravell if I do it manually I have no problem as in this example: https://protobuf-net.github.io/protobuf-net.Grpc/gettingstarted#2-implement-the-client
But on the other hand, if I do it with the factory I lose access to this instance? There is no way to get some kind of reference?
I am using gRPC with Unity and because of the nature of Unity, I need to manually dispose the channel instance when exiting play mode.
gRPC executes code in other threads and this generates problems in Unity when exiting play mode.