SlideShare a Scribd company logo
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Work
Unity
Private
https://medium.com/@neuecc http://neue.cc/
@neuecc
https://github.com/neuecc/UniRx
Mobile JRPG
https://kuro-kishi.jp
Unity
ASP.NET
Photon
Main feature on Game
Chat and Notification
Support C#!
Can be able to write logic in server
Have many cases in Unity
PUN(Photon Unity Network)
We don’t use PUN,
use Client SDK(with Own Framework)
Getting Started
Photon Server
It is class library
Execution flow
public class Startup : ApplicationBase
{
// create connection when connected on server
protected override PeerBase CreatePeer(InitRequest initRequest)
{
if (/* from client request */)
{
return new MyClientPeer(initRequest);
}
else // from server request
{
return new InboundS2SPeer(initRequest);
}
}
protected override void Setup()
{
// Launching process
// Connect to master server
var outboundPeer = new OutboundS2SPeer();
outboundPeer.ConnectTcp();
}
protected override void TearDown()
{
// Quitting process
}
}
public class MyClientPeer : ClientPeer
{
public MyClientPeer(InitRequest initRequest)
: base(initRequest)
{
}
protected override void OnOperationRequest(OperationRequest operationRequest,
{
// byte: operationRequest.OperationCode
// Dictionary<byte, object>: operationRequest.Parameters
// Send response to client
this.SendOperationResponse(new OperationResponse(), sendParameters);
}
protected override void OnDisconnect(DisconnectReason reasonCode, string reaso
{
}
}
// 1. from Unity to Server
var peer = new ClientSidePeer(new MyListener());
peer.OpCustom(opCode: 10, parameter: new Dictionary<byte, object>());
// 2. Receive on Server
protected override void OnOperationRequest(OperationRequest operationRequest)
{
// switch by opCode
switch (operationRequest.OperationCode)
{
case 10:
// Parameter from dictionary(<byte, object>)
var parameter = operationRequest.Parameters;
/* process request */
// 3. Send result to client
this.SendOperationResponse(new OperationResponse(operationCode: 5));
break;
default:
break;
}
}
// Unity Client
public class MyListener : IPhotonPeerListener
{
// 4. Received from Server
public void OnOperationResponse(OperationResponse operationResponse)
{
// Return response
switch (operationResponse.OperationCode)
{
case 5:
// process response
break;
}
}
}
// 3. Server: Send result to client
this.SendOperationResponse(new OperationResponse(operationCode: 5), sendParameters);
// switch by opCode
switch (operationRequest.OperationCode)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break
case 10:
// switch by opCode
switch (operationRequest.OperationCode)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
// switch by opCode
switch (operationRequest.OperationCo
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Intro to PhotonWire
send byte, Dictionary and switch and switch
Can not track send-receive message
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Typed Asynchronous RPC Layer
https://github.com/neuecc/PhotonWire
Windows Client
Server to Server
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity
Next PhotonWire
DESERIALIZE SPEED
Replacing serializer
(De)serialize is slow in Unity
ScriptableObject > JsonUtility > *** > MsgPack > XxxJSON
New WireFormat which does not Deserialize
Fit to C# and Unity
Will be available soon
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity

More Related Content

What's hot (20)

PPTX
Choosing the right parallel compute architecture
corehard_by
 
PDF
Functional Reactive Programming on Android
Sam Lee
 
PPTX
All you need to know about the JavaScript event loop
Saša Tatar
 
PDF
NodeJS: an Introduction
Roberto Casadei
 
PDF
Understanding greenlet
Saúl Ibarra Corretgé
 
ODP
Docker meetup
Ruslan Lutsenko
 
PPTX
JavaScript Engines and Event Loop
Tapan B.K.
 
PDF
[2014 CodeEngn Conference 11] 정든품바 - 웹성코드
GangSeok Lee
 
PDF
Swift server-side-let swift2016
Eric Ahn
 
PDF
Code quality par Simone Civetta
CocoaHeads France
 
PDF
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
NAVER D2
 
PDF
Developer support/process automation tools
Dmitry Vyukov
 
PDF
OneRing @ OSCamp 2010
Qiangning Hong
 
PDF
Comet with node.js and V8
amix3k
 
PDF
syzbot and the tale of million kernel bugs
Dmitry Vyukov
 
PPTX
PVS-Studio for Linux (CoreHard presentation)
Andrey Karpov
 
PDF
objection - runtime mobile exploration
SensePost
 
PDF
syzkaller: the next gen kernel fuzzer
Dmitry Vyukov
 
PPT
Javaone2008 Bof 5102 Groovybuilders
Andres Almiray
 
PDF
Couverture de code
CocoaHeads France
 
Choosing the right parallel compute architecture
corehard_by
 
Functional Reactive Programming on Android
Sam Lee
 
All you need to know about the JavaScript event loop
Saša Tatar
 
NodeJS: an Introduction
Roberto Casadei
 
Understanding greenlet
Saúl Ibarra Corretgé
 
Docker meetup
Ruslan Lutsenko
 
JavaScript Engines and Event Loop
Tapan B.K.
 
[2014 CodeEngn Conference 11] 정든품바 - 웹성코드
GangSeok Lee
 
Swift server-side-let swift2016
Eric Ahn
 
Code quality par Simone Civetta
CocoaHeads France
 
[214] Ai Serving Platform: 하루 수 억 건의 인퍼런스를 처리하기 위한 고군분투기
NAVER D2
 
Developer support/process automation tools
Dmitry Vyukov
 
OneRing @ OSCamp 2010
Qiangning Hong
 
Comet with node.js and V8
amix3k
 
syzbot and the tale of million kernel bugs
Dmitry Vyukov
 
PVS-Studio for Linux (CoreHard presentation)
Andrey Karpov
 
objection - runtime mobile exploration
SensePost
 
syzkaller: the next gen kernel fuzzer
Dmitry Vyukov
 
Javaone2008 Bof 5102 Groovybuilders
Andres Almiray
 
Couverture de code
CocoaHeads France
 

Viewers also liked (18)

PDF
linq.js - Linq to Objects for JavaScript
Yoshifumi Kawai
 
PDF
LINQPad with LINQ to BigQuery - Desktop Client for BigQuery
Yoshifumi Kawai
 
PDF
How to make the Fastest C# Serializer, In the case of ZeroFormatter
Yoshifumi Kawai
 
PPTX
linq.js ver.3 and JavaScript in Visual Studio 2012
Yoshifumi Kawai
 
PDF
LINQ in Unity
Yoshifumi Kawai
 
PDF
ZeroFormatter/MagicOnion - Fastest C# Serializer/gRPC based C# RPC
Yoshifumi Kawai
 
PDF
Introduction to NotifyPropertyChangedGenerator
Yoshifumi Kawai
 
PPTX
Clash of Oni Online - VR Multiplay Sword Action
Yoshifumi Kawai
 
PDF
Observable Everywhere - Rxの原則とUniRxにみるデータソースの見つけ方
Yoshifumi Kawai
 
PDF
What, Why, How Create OSS Libraries - 過去に制作した30のライブラリから見るC#コーディングテクニックと個人OSSの...
Yoshifumi Kawai
 
PDF
History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法
Yoshifumi Kawai
 
PDF
Photon Server Deep Dive - PhotonWireの実装から見つめるPhotonServerの基礎と応用
Yoshifumi Kawai
 
PDF
Metaprogramming Universe in C# - 実例に見るILからRoslynまでの活用例
Yoshifumi Kawai
 
PDF
Binary Reading in C#
Yoshifumi Kawai
 
PDF
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
Yoshifumi Kawai
 
PDF
NextGen Server/Client Architecture - gRPC + Unity + C#
Yoshifumi Kawai
 
PPTX
RuntimeUnitTestToolkit for Unity
Yoshifumi Kawai
 
PDF
「黒騎士と白の魔王」gRPCによるHTTP/2 - API, Streamingの実践
Yoshifumi Kawai
 
linq.js - Linq to Objects for JavaScript
Yoshifumi Kawai
 
LINQPad with LINQ to BigQuery - Desktop Client for BigQuery
Yoshifumi Kawai
 
How to make the Fastest C# Serializer, In the case of ZeroFormatter
Yoshifumi Kawai
 
linq.js ver.3 and JavaScript in Visual Studio 2012
Yoshifumi Kawai
 
LINQ in Unity
Yoshifumi Kawai
 
ZeroFormatter/MagicOnion - Fastest C# Serializer/gRPC based C# RPC
Yoshifumi Kawai
 
Introduction to NotifyPropertyChangedGenerator
Yoshifumi Kawai
 
Clash of Oni Online - VR Multiplay Sword Action
Yoshifumi Kawai
 
Observable Everywhere - Rxの原則とUniRxにみるデータソースの見つけ方
Yoshifumi Kawai
 
What, Why, How Create OSS Libraries - 過去に制作した30のライブラリから見るC#コーディングテクニックと個人OSSの...
Yoshifumi Kawai
 
History & Practices for UniRx UniRxの歴史、或いは開発(中)タイトルの用例と落とし穴の回避法
Yoshifumi Kawai
 
Photon Server Deep Dive - PhotonWireの実装から見つめるPhotonServerの基礎と応用
Yoshifumi Kawai
 
Metaprogramming Universe in C# - 実例に見るILからRoslynまでの活用例
Yoshifumi Kawai
 
Binary Reading in C#
Yoshifumi Kawai
 
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
Yoshifumi Kawai
 
NextGen Server/Client Architecture - gRPC + Unity + C#
Yoshifumi Kawai
 
RuntimeUnitTestToolkit for Unity
Yoshifumi Kawai
 
「黒騎士と白の魔王」gRPCによるHTTP/2 - API, Streamingの実践
Yoshifumi Kawai
 
Ad

Similar to Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity (20)

PDF
Photon For Unity
Dat Pham
 
PDF
Unity and WebSockets
Josh Glover
 
PPTX
Unity networking
Minh Tuan
 
PPTX
Real time websites and mobile apps with SignalR
Roy Cornelissen
 
PDF
Active object of Symbian in the lights of client server architecture
Somenath Mukhopadhyay
 
PDF
Real time event feeds with NServiceBus and SignalR
Roy Cornelissen
 
PPTX
F# Server-side programming
7sharp9
 
PPTX
Photon Session / Unite12 Conference
Christof Wegmann
 
PDF
F# and SignalR for a FastWeb
Riccardo Terrell
 
PPT
Multiplayer Games Chapter 6 Network Topologies.ppt
MoissFreitas13
 
PDF
38199728 multi-player-tutorial
alfrecaay
 
PPTX
NServiceBus workshop presentation
Tomas Jansson
 
PDF
Time for Functions
simontcousins
 
PDF
Combining the Strengths or Erlang and Ruby
Wooga
 
PDF
Combining the strength of erlang and Ruby
Martin Rehfeld
 
PDF
CHAPTER 24.pdfhehbebbebebbebbeebbebbebeb
kittycatcatcat123456
 
PPSX
Signalr with ASP.Net part2
Esraa Ammar
 
PDF
Introduction to NServiceBus
Espen Ekvang
 
PPTX
Connected Web Systems
Damir Dobric
 
PDF
F# in social gaming by Yan Cui at Codemotion Dubai
Codemotion Dubai
 
Photon For Unity
Dat Pham
 
Unity and WebSockets
Josh Glover
 
Unity networking
Minh Tuan
 
Real time websites and mobile apps with SignalR
Roy Cornelissen
 
Active object of Symbian in the lights of client server architecture
Somenath Mukhopadhyay
 
Real time event feeds with NServiceBus and SignalR
Roy Cornelissen
 
F# Server-side programming
7sharp9
 
Photon Session / Unite12 Conference
Christof Wegmann
 
F# and SignalR for a FastWeb
Riccardo Terrell
 
Multiplayer Games Chapter 6 Network Topologies.ppt
MoissFreitas13
 
38199728 multi-player-tutorial
alfrecaay
 
NServiceBus workshop presentation
Tomas Jansson
 
Time for Functions
simontcousins
 
Combining the Strengths or Erlang and Ruby
Wooga
 
Combining the strength of erlang and Ruby
Martin Rehfeld
 
CHAPTER 24.pdfhehbebbebebbebbeebbebbebeb
kittycatcatcat123456
 
Signalr with ASP.Net part2
Esraa Ammar
 
Introduction to NServiceBus
Espen Ekvang
 
Connected Web Systems
Damir Dobric
 
F# in social gaming by Yan Cui at Codemotion Dubai
Codemotion Dubai
 
Ad

More from Yoshifumi Kawai (12)

PDF
A quick tour of the Cysharp OSS
Yoshifumi Kawai
 
PDF
A Brief History of UniRx/UniTask, IUniTaskSource in Depth
Yoshifumi Kawai
 
PDF
Building the Game Server both API and Realtime via c#
Yoshifumi Kawai
 
PDF
ライブラリ作成のすゝめ - 事例から見る個人OSS開発の効能
Yoshifumi Kawai
 
PDF
Unityによるリアルタイム通信とMagicOnionによるC#大統一理論の実現
Yoshifumi Kawai
 
PDF
Unity C#と.NET Core(MagicOnion) C# そしてKotlinによるハーモニー
Yoshifumi Kawai
 
PDF
Implements OpenTelemetry Collector in DotNet
Yoshifumi Kawai
 
PDF
The Usage and Patterns of MagicOnion
Yoshifumi Kawai
 
PDF
True Cloud Native Batch Workflow for .NET with MicroBatchFramework
Yoshifumi Kawai
 
PDF
Memory Management of C# with Unity Native Collections
Yoshifumi Kawai
 
PDF
Deep Dive async/await in Unity with UniTask(UniRx.Async)
Yoshifumi Kawai
 
PDF
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭する
Yoshifumi Kawai
 
A quick tour of the Cysharp OSS
Yoshifumi Kawai
 
A Brief History of UniRx/UniTask, IUniTaskSource in Depth
Yoshifumi Kawai
 
Building the Game Server both API and Realtime via c#
Yoshifumi Kawai
 
ライブラリ作成のすゝめ - 事例から見る個人OSS開発の効能
Yoshifumi Kawai
 
Unityによるリアルタイム通信とMagicOnionによるC#大統一理論の実現
Yoshifumi Kawai
 
Unity C#と.NET Core(MagicOnion) C# そしてKotlinによるハーモニー
Yoshifumi Kawai
 
Implements OpenTelemetry Collector in DotNet
Yoshifumi Kawai
 
The Usage and Patterns of MagicOnion
Yoshifumi Kawai
 
True Cloud Native Batch Workflow for .NET with MicroBatchFramework
Yoshifumi Kawai
 
Memory Management of C# with Unity Native Collections
Yoshifumi Kawai
 
Deep Dive async/await in Unity with UniTask(UniRx.Async)
Yoshifumi Kawai
 
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭する
Yoshifumi Kawai
 

Recently uploaded (20)

PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
PDF
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PDF
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
PDF
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
PPTX
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PDF
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
Quantum Threats Are Closer Than You Think – Act Now to Stay Secure
WSO2
 
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
Bitkom eIDAS Summit | European Business Wallet: Use Cases, Macroeconomics, an...
Carsten Stoecker
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
My Journey from CAD to BIM: A True Underdog Story
Safe Software
 
Unlocking FME Flow’s Potential: Architecture Design for Modern Enterprises
Safe Software
 
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
Proactive Server and System Monitoring with FME: Using HTTP and System Caller...
Safe Software
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
Practical Applications of AI in Local Government
OnBoard
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 

Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer Framework for Unity

  • 4. Main feature on Game Chat and Notification
  • 5. Support C#! Can be able to write logic in server Have many cases in Unity
  • 6. PUN(Photon Unity Network) We don’t use PUN, use Client SDK(with Own Framework)
  • 8. It is class library Execution flow
  • 9. public class Startup : ApplicationBase { // create connection when connected on server protected override PeerBase CreatePeer(InitRequest initRequest) { if (/* from client request */) { return new MyClientPeer(initRequest); } else // from server request { return new InboundS2SPeer(initRequest); } } protected override void Setup() { // Launching process // Connect to master server var outboundPeer = new OutboundS2SPeer(); outboundPeer.ConnectTcp(); } protected override void TearDown() { // Quitting process } } public class MyClientPeer : ClientPeer { public MyClientPeer(InitRequest initRequest) : base(initRequest) { } protected override void OnOperationRequest(OperationRequest operationRequest, { // byte: operationRequest.OperationCode // Dictionary<byte, object>: operationRequest.Parameters // Send response to client this.SendOperationResponse(new OperationResponse(), sendParameters); } protected override void OnDisconnect(DisconnectReason reasonCode, string reaso { } }
  • 10. // 1. from Unity to Server var peer = new ClientSidePeer(new MyListener()); peer.OpCustom(opCode: 10, parameter: new Dictionary<byte, object>()); // 2. Receive on Server protected override void OnOperationRequest(OperationRequest operationRequest) { // switch by opCode switch (operationRequest.OperationCode) { case 10: // Parameter from dictionary(<byte, object>) var parameter = operationRequest.Parameters; /* process request */ // 3. Send result to client this.SendOperationResponse(new OperationResponse(operationCode: 5)); break; default: break; } }
  • 11. // Unity Client public class MyListener : IPhotonPeerListener { // 4. Received from Server public void OnOperationResponse(OperationResponse operationResponse) { // Return response switch (operationResponse.OperationCode) { case 5: // process response break; } } } // 3. Server: Send result to client this.SendOperationResponse(new OperationResponse(operationCode: 5), sendParameters);
  • 12. // switch by opCode switch (operationRequest.OperationCode) { case 0: break; case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; case 7: break; case 8: break; case 9: break case 10:
  • 13. // switch by opCode switch (operationRequest.OperationCode) { case 0: break; case 1: break; case 2: break; case 3: break; case 4: break; case 5:
  • 14. // switch by opCode switch (operationRequest.OperationCo { case 0: break; case 1: break; case 2: break; case 3: break;
  • 17. send byte, Dictionary and switch and switch Can not track send-receive message
  • 20. Typed Asynchronous RPC Layer https://github.com/neuecc/PhotonWire
  • 31. (De)serialize is slow in Unity ScriptableObject > JsonUtility > *** > MsgPack > XxxJSON
  • 32. New WireFormat which does not Deserialize Fit to C# and Unity Will be available soon