From 1bb8a7067289149fd6bdce9bec864dff5403e5b1 Mon Sep 17 00:00:00 2001 From: neuecc Date: Mon, 9 Sep 2019 21:18:26 +0900 Subject: [PATCH] build(copy) to unity --- .../Assets/Scripts/MagicOnion/Client/ClientFilter.cs | 9 ++++++++- .../Scripts/MagicOnion/Client/MagicOnionClientBase.cs | 8 ++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/ClientFilter.cs b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/ClientFilter.cs index 18bd27dbb..76d0bfd5e 100644 --- a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/ClientFilter.cs +++ b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/ClientFilter.cs @@ -21,6 +21,7 @@ public abstract class RequestContext public Type ResponseType { get; } public abstract Type RequestType { get; } public Func RequestMutator { get; private set; } + public Func ResponseMutator { get; private set; } Dictionary items; public IDictionary Items @@ -49,12 +50,18 @@ internal RequestContext(MagicOnionClientBase client, string methodPath, CallOpti this.Filters = filters; this.RequestMethod = requestMethod; this.RequestMutator = DefaultMutator; + this.ResponseMutator = DefaultMutator; } public void SetRequestMutator(Func mutator) { this.RequestMutator = mutator; } + + public void SetResponseMutator(Func mutator) + { + this.ResponseMutator = mutator; + } } public class RequestContext : RequestContext @@ -100,7 +107,7 @@ public ResponseContext() this.ResponseMutator = DefaultMutator; } - public void SetRequestMutator(Func mutator) + public void SetResponseMutator(Func mutator) { this.ResponseMutator = mutator; } diff --git a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/MagicOnionClientBase.cs b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/MagicOnionClientBase.cs index 591de64b0..567eb3ffa 100644 --- a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/MagicOnionClientBase.cs +++ b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/MagicOnionClientBase.cs @@ -18,7 +18,9 @@ static protected ResponseContext CreateResponseContext(RequestContext { var self = context.Client; var callResult = self.callInvoker.AsyncUnaryCall(method, self.host, context.CallOptions, context.RequestMutator(MagicOnionMarshallers.UnsafeNilBytes)); - return new ResponseContext(callResult, self.resolver); + var response = new ResponseContext(callResult, self.resolver); + response.SetResponseMutator(context.ResponseMutator); + return response; } static protected ResponseContext CreateResponseContext(RequestContext context, Method method) @@ -26,7 +28,9 @@ static protected ResponseContext CreateResponseContext(Requ var self = context.Client; var message = LZ4MessagePackSerializer.Serialize(((RequestContext)context).Request, self.resolver); var callResult = self.callInvoker.AsyncUnaryCall(method, self.host, context.CallOptions, context.RequestMutator(message)); - return new ResponseContext(callResult, self.resolver); + var response = new ResponseContext(callResult, self.resolver); + response.SetResponseMutator(context.ResponseMutator); + return response; } }