Comments (3)
I'm using MagicOnion.UnaryHookCallInvoker
.
It can handle UnaryCall.
This is sample of our usage.
public class HandleErrorInvoker : UnaryHookCallInvoker
{
protected override IObservable<TResponse> HandleUnaryCall<TRequest, TResponse>(IObservable<TResponse> source, CallInvocationDetails<TRequest, TResponse> details, Func<Metadata> getTrailers)
{
return source
.Do(_ =>
{
// our internal custom logics...
var metadata = getTrailers();
long serverTime = 0;
if (long.TryParse(metadata.GetValue("x-servertime"), out serverTime))
{
Scheduler.MainThread.Schedule(() =>
{
Grani.Core.SystemClock.SetServerTime(DateTime.FromBinary(serverTime), Time.realtimeSinceStartup);
});
}
})
.Catch((Exception ex) =>
{
// out custom execption handling
var next = new Subject<TResponse>();
Scheduler.MainThread.Schedule(() =>
{
switch (HandleCommonError(ex)) // do custom logic and get result.
{
case HandleCommonErrorResult.Rethrow:
next.OnError(ex);
break;
case HandleCommonErrorResult.Empty:
next.OnCompleted();
break;
case HandleCommonErrorResult.Never:
break;
}
});
return next;
});
}
}
from magiconion.
thanks for your advice, but when I tried to do the work, I found the unaryhookinvoker is in the magiconion.unity package, my client is asp.net webapi, should I reference the magiconion.unity? I feel it's not good, I tried to implement unaryhookinvoker by myself, however, some reference code of grpc is internal.
from magiconion.
The hook point of Unary currently of gRPC is obviously small. In the Unity version, we could deal with it by changing it ourselves, but if it is not so, we can not do it.
MagicOnionClient side may set up its own hook point, which may be able to cope with this problem.
I'll think about it.
from magiconion.
Related Issues (20)
- Incorrect deserialize on using Unity client and MemoryPack HOT 4
- MagicOnion.Generated.cs fails to compile in unity HOT 6
- StreamingHubClientBase exception handling error
- Unhandleable exceptions when connecting HOT 1
- Question: any thoughts on reliable UDP or QUIC? And QoS?
- Question: How can I connect the TLS protocol to the new version (v5.1.8)? HOT 1
- Question: Possible to use Task and ValueTask instead of UnaryResult and such? HOT 1
- Question: ObjectDisposedException on proxy side
- Question: Is a MagicOnion server possible from within Unity?
- can support Webgl http2 and net8?
- I can't have multiple implementations!
- .NET 8 Support
- Client filter is not triggered for ServerStreamingResult method in services. HOT 1
- Performance is very slow, taking 355ms for the Add function to return the result HOT 2
- How can I disconnect a client by server?
- InternalsVisibleTo lead to warnings on dependent project HOT 1
- Implement Protobuf Endpoint
- ServerReflection does not work
- Cannot work after changing to MemoryPack HOT 2
- Console app probem: PlatformNotSupportedException HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magiconion.