Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Done UnityClient Runtime, Unity Code Generator
- Loading branch information
Showing
210 changed files
with
6,525 additions
and
759 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
9 changes: 9 additions & 0 deletions
9
src/MagicOnion.Client.Unity/Assets/Plugins/ZeroFormatter.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file added
BIN
+16.5 KB
src/MagicOnion.Client.Unity/Assets/Plugins/ZeroFormatter/ZeroFormatter.Interfaces.dll
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
src/MagicOnion.Client.Unity/Assets/Plugins/ZeroFormatter/ZeroFormatter.Interfaces.dll.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file added
BIN
+102 KB
src/MagicOnion.Client.Unity/Assets/Plugins/ZeroFormatter/ZeroFormatter.dll
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
src/MagicOnion.Client.Unity/Assets/Plugins/ZeroFormatter/ZeroFormatter.dll.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
93 changes: 0 additions & 93 deletions
93
src/MagicOnion.Client.Unity/Assets/Plugins/gRPC/Core/Utils/CancellationTokenWithCallback.cs
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
62 changes: 62 additions & 0 deletions
62
src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/AsyncStreamReaderExtensions.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,62 @@ | ||
using Grpc.Core; | ||
using System; | ||
using UniRx; | ||
|
||
namespace MagicOnion | ||
{ | ||
public static class AsyncStreamReaderExtensions | ||
{ | ||
//TODO:implement Observbale.While | ||
public static IObservable<Unit> ForEachAsync<T>(this IAsyncStreamReader<T> stream, Action<T> action) | ||
{ | ||
return RecursiveAction(stream, action); | ||
} | ||
|
||
static IObservable<Unit> RecursiveAction<T>(IAsyncStreamReader<T> stream, Action<T> action) | ||
{ | ||
return stream.MoveNext().ContinueWith(x => | ||
{ | ||
if (x) | ||
{ | ||
action(stream.Current); | ||
return RecursiveAction(stream, action); | ||
} | ||
else | ||
{ | ||
stream.Dispose(); | ||
return Observable.ReturnUnit(); | ||
} | ||
}); | ||
} | ||
|
||
public static IObservable<Unit> ForEachAsync<T>(this IAsyncStreamReader<T> stream, Func<T, IObservable<Unit>> asyncAction) | ||
{ | ||
return RecursiveActionAsync(stream, asyncAction); | ||
} | ||
|
||
static IObservable<Unit> RecursiveActionAsync<T>(IAsyncStreamReader<T> stream, Func<T, IObservable<Unit>> asyncAction) | ||
{ | ||
return stream.MoveNext().ContinueWith(x => | ||
{ | ||
if (x) | ||
{ | ||
return asyncAction(stream.Current) | ||
.ContinueWith(_ => RecursiveActionAsync(stream, asyncAction)); | ||
} | ||
else | ||
{ | ||
stream.Dispose(); | ||
return Observable.ReturnUnit(); | ||
} | ||
}); | ||
} | ||
|
||
// TODO:needs strict implementation | ||
public static IObservable<T> AsObservable<T>(this IAsyncStreamReader<T> stream) | ||
{ | ||
var subject = new Subject<T>(); | ||
stream.ForEachAsync(x => subject.OnNext(x)); // cancellation! | ||
return subject; | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...ils/CancellationTokenWithCallback.cs.meta → ...Onion/AsyncStreamReaderExtensions.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
44 changes: 44 additions & 0 deletions
44
src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/MagicOnionClient.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,44 @@ | ||
using Grpc.Core; | ||
using System; | ||
using ZeroFormatter.Formatters; | ||
|
||
namespace MagicOnion.Client | ||
{ | ||
public static class MagicOnionClient | ||
{ | ||
public static T Create<T>(Channel channel) | ||
where T : IService<T> | ||
{ | ||
return MagicOnionClientRegistry<T>.Create(channel); | ||
} | ||
|
||
public static T Create<T>(CallInvoker invoker) | ||
where T : IService<T> | ||
{ | ||
return MagicOnionClientRegistry<T>.Create(invoker); | ||
} | ||
} | ||
|
||
public static class MagicOnionClientRegistry<T> | ||
where T : IService<T> | ||
{ | ||
static Func<Channel, T> consturtor1; | ||
static Func<CallInvoker, T> consturtor2; | ||
|
||
public static void Register(Func<Channel, T> ctor1, Func<CallInvoker, T> ctor2) | ||
{ | ||
consturtor1 = ctor1; | ||
consturtor2 = ctor2; | ||
} | ||
|
||
public static T Create(Channel channel) | ||
{ | ||
return consturtor1(channel); | ||
} | ||
|
||
public static T Create(CallInvoker invoker) | ||
{ | ||
return consturtor2(invoker); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/Client/MagicOnionClient.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.