-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility for callee instance to return an observable
- Loading branch information
Johan 't Hart
committed
Mar 3, 2021
1 parent
fe62d3e
commit 5bf516f
Showing
5 changed files
with
109 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...d/WampSharp/WAMP2/V2/Rpc/Callee/Reflection/ProgressiveObservableMethodInfoRpcOperation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Threading; | ||
using WampSharp.Core.Utilities; | ||
using WampSharp.Core.Serialization; | ||
using WampSharp.V2.Core.Contracts; | ||
|
||
namespace WampSharp.V2.Rpc | ||
{ | ||
public class ProgressiveObservableMethodInfoRpcOperation<T> : SyncMethodInfoRpcOperation | ||
{ | ||
public ProgressiveObservableMethodInfoRpcOperation(Func<object> instanceProvider, MethodInfo method, string procedureName) : | ||
base(instanceProvider, method, procedureName) | ||
{ | ||
} | ||
|
||
protected override void OnResult(IWampRawRpcOperationRouterCallback caller, object result, IDictionary<string, object> outputs) | ||
{ | ||
((IObservable<T>)result).Subscribe( | ||
it => CallResult(caller, it, outputs, new YieldOptions { Progress = true }), | ||
ex => | ||
{ | ||
if (ex is WampException wampex) | ||
HandleException(caller, wampex); | ||
else | ||
HandleException(caller, ex); | ||
}, | ||
// An observable does not emit any value when completing, so result without arguments | ||
() => caller.Result(ObjectFormatter, new YieldOptions()) | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters