SlideShare a Scribd company logo
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
C# /
UniRx
Yoshifumi Kawai
CTOGrani, Inc.
About speaker
•
•
•
•
•
•
•
•
•
About this session
•
•
About this session
•
•
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
• 4 NPC
• 4 vs 4
• C#
• AI
•
• UniRx
• LINQ to GameObject
• MessagePack for C#
• MagicOnion
• MasterMemory
• ReMotion
• by Yoshifumi Kawai
• etc...
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
using
Why C#?
Why Unity?
•
•
•
•
•
•
•
•
•
C#
•
•
•
•
•
•
•
•
•
How to
•
•
•
•
)
•
•
•
• IDL(Interface Definiton Language)
• IDL = JSON proto /
• IDL ……
• IDL
• C#
• IDL
IDL
• Visual Studio
•
• Unity
• Git
• ……
• C#
• C#
•
•
Visual Studio
C# C#
• C# C#
• C# 6.0(Visual Studio 2015)
•
• [MessagePackObject] => ***MessagePackFormatter
• /
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
•
•
•
• /
•
•
•
•
•
•
•
• /
•
•
•
•
•
• /
•
• /
•
•
•
•
• /
•
• /
•
•
•
C#
• C# /
•
•
•
•
• /
•
IDL
•
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
•
• C#
• ……
•
•
•
•
•
•
3
gRPC
• Web API + Streaming
• Google HTTP/2 RPC
• HTTP/2 HTTP/1
• gRPC
• Web API
• (Unity )
• (Unity Web API )
google
gRPC
• Web API + Streaming
• Google HTTP/2 RPC
• HTTP/2 HTTP/1
• gRPC
• Web API
• (Unity )
• (Unity Web API )
google
Unity gRPC
• C# gRPC Unity
• .NET 4.5
•
• gRPC Client Unity
• .NET 3.5 + IL2CPP
• (C Core) iOS/Android
• /
• gRPC IDL Protocol Buffers
/ Unity
• HTTP/2 gRPC
Unity gRPC
• C# gRPC Unity
• .NET 4.5
•
• gRPC Client Unity
• .NET 3.5 + IL2CPP
• (C Core) iOS/Android
• /
• gRPC IDL Protocol Buffers
/ Unity
• HTTP/2 gRPC
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
•
•
•
•
•
•
•
•
• ……
•
•
•
•
•
•
•
•
• ……
UNET
• Unity
•
•
•
• C#
•
• UNET
• C#
•
• Web API ,
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
Web API
•
•
•
•
•
•
•
•
•
Web API
•
•
•
•
•
•
•
•
•
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
• Web API
Streaming Service(gRPC Battle Engine)
F for AI
• AI (DSL) F#
• F# .NET Framework
• Excel F#
C# gRPC BattleEngine
• AI
Streaming Server
•
•
•
•
•
•
•
•
•
•
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
We’re using UniRx
•
•
•
•
•
•
•
We’re using UniRx
•
•
•
•
•
•
•
UniRx
•
•
•
•
•
•
•
•
•
• : 3845 : 1186
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
Rx
•
•
•
•
•
Rx 3
// これで例外を共通ハンドリング
IObservable<TResponse> HnadleCommonError<TRequest, TResponse>(IObservable<TResponse> source
{
return source
.Catch((Exception ex) =>
{
// Exception使って共通エラーポップアップを出したりするとする
NavigationService.ShowMessagePopUpAsync("error", "errorMessage").Subscribe();
// 呼び元に真の意味で何も返さない
return Observable.Never<TResponse>();
});
}
Pitfall of Empty
•
•
IObservable<Unit> Test()
{
return Observable.FromCoroutine(() => TestCore());
}
IEnumerator TestCore()
{
yield return Observable.Empty<int>().ToYieldInstruction();
Debug.Log(“この行には到達する");
}
Pitfall of Empty
•
•
IObservable<Unit> Test()
{
return Observable.FromCoroutine(() => TestCore());
}
IEnumerator TestCore()
{
yield return Observable.Empty<int>().ToYieldInstruction();
Debug.Log("come here");
}
UI Framework Rx
•
•
•
•
•
•
•
•
Chaotic Rx
•
•
•
•
•
Ivory.Unity.Core.Scene.<OnAfterNavigate>c__AnonStorey76A:<>m__2DC7(Unit)
UniRx.Operators.Do:OnNext(Unit)
UniRx.Operators.ImmutableReturnUnitObservable:Subscribe(IObserver`1)
UniRx.Operators.Do:Run()
UniRx.Operators.DoObservable`1:SubscribeCore(IObserver`1, IDisposable)
UniRx.Operators.OperatorObservableBase`1:Subscribe(IObserver`1)
UniRx.Operators.OperatorObservableBase`1:Subscribe(IObserver`1)
UniRx.Operators.SelectManyOuterObserver:OnNext(Unit)
UniRx.Operators.SelectMany:OnNext(Unit)
UniRx.Operators.SelectMany:OnNext(Unit)
UniRx.Operators.SelectMany:OnNext(Unit)
UniRx.Operators.Do:OnNext(Unit)
UniRx.Operators.SelectMany:OnNext(Unit)
UniRx.Operators.SelectManyOuterObserver:OnNext(Unit)
UniRx.Operators.Do:OnNext(Unit)
UniRx.Operators.ImmutableReturnUnitObservable:Subscribe(IObserver`1)
UniRx.Operators.Do:Run()
UniRx.Operators.DoObservable`1:SubscribeCore(IObserver`1, IDisposable)
UniRx.Operators.OperatorObservableBase`1:Subscribe(IObserver`1)
UniRx.Operators.SelectManyOuterObserver:Run()
UniRx.Operators.SelectManyObservable`2:SubscribeCore(IObserver`1, IDisposable)
UniRx.Operators.OperatorObservableBase`1:Subscribe(IObserver`1)
UniRx.Operators.Do:Run()
UniRx.Operators.DoObservable`1:SubscribeCore(IObserver`1, IDisposable)
UniRx.Operators.OperatorObservableBase`1:Subscribe(IObserver`1)
UniRx.Operators.SelectManyOuterObserver:OnNext(Unit)
UniRx.Operators.SelectMany:OnNext(Unit)
UniRx.Operators.WhenAll_:OnNext(Unit)
UniRx.Operators.WhenAllCollectionObserver:OnCompleted()
UniRx.Operators.AsUnitObservable:OnCompleted()
UniRx.Operators.WhenAll:OnCompleted()
UniRx.Operators.WhenAllCollectionObserver:OnCompleted()
UniRx.Operators.ImmutableReturnUnitObservable:Subscribe(IObserver`1)
Model-View-(Reacitve)Presenter
View
Reactive
Presenter
Model
Model-View-(Reacitve)Presenter
View
Reactive
Presenter
Model
Chaotic-Reacitve-Model
Reactive
Presenter
Model
Chaotic-Reacitve-Model
Reactive
Presenter
Model
Rx Simplicity
•
•
•
•
•
•
•
•
•
•
Rx
•
•
•
•
•
•
•
•
•
•
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
• Before gRPC
•
•
•
•
•
• After gRPC
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
ZeroFormatter
•
•
•
•
•
•
•
•
•
•
•
•
•
•
MessagePack for C#
C#
•
•
•
•
•
•
•
•
•
C#
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
DB
•
•
•
•
Architecture of MasterMemory
Header LZ4+MsgPack LZ4+MsgPack LZ4+MsgPack LZ4+MsgPack
Memory<T>
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術
The Future Has Come
•
• C#
•
•
•
•
•
•
We're Hiring
Unity Engineer/Technical Artist
http://recruit.grani.jp/
Thank you!

More Related Content

【Unite 2017 Tokyo】「黒騎士と白の魔王」にみるC#で統一したサーバー/クライアント開発と現実的なUniRx使いこなし術