Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Goだけでロビーサーバーを作ってみた
Search
irieda
October 05, 2018
Programming
2
500
Goだけでロビーサーバーを作ってみた
GoとGopherJSによるIsomorphicな実装で
P2Pメッシュを確立できるロビーサーバーを作ってみた話。
irieda
October 05, 2018
Tweet
Share
More Decks by irieda
See All by irieda
SpaGoでSPAを作ろう!
nobonobo
0
560
TinyGoでIoTを始めよう
nobonobo
2
780
GopherJS+Vecty
nobonobo
1
860
Other Decks in Programming
See All in Programming
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
Jakarta EE meets AI
ivargrimstad
0
140
Arm移行タイムアタック
qnighy
0
320
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
100
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
KATA
mclloyd
29
14k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Ruby is Unlike a Banana
tanoku
97
11k
We Have a Design System, Now What?
morganepeng
50
7.2k
A Tale of Four Properties
chriscoyier
156
23k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Transcript
Go ͚ͩͰ ʓʓʓʓΛ࡞ͬͯΈͨ
͓લ୭Αʁ ًؕزٗاؿز㾊 1ZUIPOJTUB(PQIFS זד(Pד剅ְׯֲמה (P娖כ䎃穗麓ְֻ ؟؎ز ⠓爡-BC ַ倜爡せ )/!OPCPOPCP IUUQHPMBOHSEZKQ
ࡢࠓͷ AltJS ࣄ
ߴڃݴޠͷ AltJS 㢌䳔דֹזְ 넝秷鎉铂ך项欵ָ⢪ִזְ 剅ֹ䩛ךأزٖأوحع ֿה׀הֻطةד穄✪
JS ϔϏʔϢʔβʔஊ &4ח㢌䳔כת䗳銲 ׃ַ׃ծ&4ך统׃כ䘌 OPK2VFSZ VTF1SPNJTF &4.ד剅ְג♧אךؿ؋؎ٕחػحָؙ植㹋鍑 "MU+4ז5ZQF4DSJQUָ剣劄
JS ͷπϥϛ ٌآُ٦ٕ堣圓ךⴓ倖 ꬊず劍ך剅ֹ倯ך㢌ꬠ劍 &4غ٦آّٝⴓ倖 㘗ָזְ㘗㼪Ⰵ䩛媮ח״ⴓ倖 ؒ؝ءأذيךⴓ倖 〢ְ٥倜׃ְ鎸鶢ה➰ֹさְ竲ֽ ײְؒٓ٦عٝسؚٔٝ
TypeScript ͳΒʁ 剑倜ך+4鎸鶢㘗ءأذيד剅ֽ 涸㘗鎉铂ך䛷䜋ָ䖤 䧭卓暟ךٌآُ٦ٕװ&4غ٦آّٝ鏣㹀ד鼅ץ +4ך项欵54ך项欵⢪ִ ا٦أوحفד54ا٦أדرغحؚ
ͦ͜Ͱ GopherJS (Pך鎸鶢㢌䳔דֹ (Pךٌآُ٦ٕ堣圓ⵃ欽 ؿ؋؎ٕחػحؙ⳿⸂ KT HP (PQIFS+4ך项欵ָׅץג⢪ִ 涸㘗鎉铂ך䛷䜋ָ䖤 ا٦أوحفד(Pا٦أדرغحؚ
ꬊず劍ך剅ֹ倯כ(Pؐؑ؎ָ然甧幥 (Pך鎸鶢כ։䎃⽃⡘ד㸜㹀׃ג 䓼㔿זؒٓ٦عٝسؚٔٝ俑⻉ 5ZQF4DSJQU״剣劄
GopherJS+Vecty (Pה(Pךワ鴟خ٦ֽٕד ؿٗٝزؒٝسָ圓眠〳腉 ׃$44כⴽ 1BTTXPSE9דך䱰欽✲⢽،ٔ CPPUTUSBQ؝ٝه٦طٝزאֻ׃ )5.-ַ7FDUZ欽鎸鶢欰䧭خ٦ٕאֻ׃ XBTN㼎䘔鹌遤⚥ 馄剣劄ה䙼ג
͜Ε·Ͱͷొஃωλ
Go ϞόΠϧͰϐΞϊ App
GopherJS ͷհ .go .js .map GopherJS
WebRTC Ͱ P2P Cloud NAT NAT Laptop Workstation Smart Phone
Tablet Wireless Access Point
ԾϥδίϯΧʔ
Go Ͱ GUI Λͭ͘Δ "bridge":QObject
Go ͚ͩͰ࡞ΔϑϩϯτΤϯυ
͜ΕΒͷొஃࢿྉʁ (PQIFS+4ד⡲גֶתׅ٦
ूେͱͯ͠ɾɾɾ
Go ͚ͩͰ TPS Λ࡞Γ·ͨ͠
ͱݴ͍͔ͨͬͨΜͰ͢ ͕ɾɾɾ
Go ͚ͩͰϩϏʔαʔόʔΛ࡞ Γ·ͨ͠ חזׯְת׃٥٥٥ s٥ω٥
࡞Δͷʹඞࢮ͗ͯ͢ࢿྉ͕͠ΐ΅͍ͷ͝༰͍ࣻͩ͘͞ɾɾɾ
ߏ ٗؽ٦؟٦غ٦ 11ًحءُطحزٙ٦ؙ 8FC6*ؿٗٝزؒٝس %ٖٝتؚٔٝ
ϩϏʔαʔόʔ 8FC35$欽ءؚشؚٔٝⰯי 8FCTPDLFUTك٦أ ず儗剑㣐,䱸竲ծ,ٕ٦ي䟝㹀 وحثؚٝ䖓11פ獳遤׃גٕ٦يכ嶊徦ׅ չ䖉فٖ؎պז,ِ٦ؠ٦ָׁלֽ فٖ؎➂〡㟓װֽׅז醱侧؟٦غ٦דأ؛٦ٕ 植朐؟٦غ٦תְوحثָؚٝדֹזְָծ 㢩鿇16#46#ָ֮לדֹ״ֲחז
P2P ϝογϡωοτϫʔΫ ؾ،כ(PQIFS+4ד圓眠 8FC35$ך35$%BUB$IBOOFMⵃ欽 ؾ،湱✼ח䱸竲ׅ ِ٦ؠ٦זぐ䱸竲ד䱸竲 鸐⥋כ11ך⡚鹼䒀 鹼䒀㼎瘻갹䓸זְדֿֿ0,
WebRTC ͱ DataChannel ֿתֳֽֿؚؚ֭ג ֿך僰װהJ044BGBSJד0,חז עׯֽإحءّٝ然甧馄וְ 1FFSה1FFSQVCTVC؟٦غ٦⢪גאזּךח ⚺㼪埄ָ❛✼ח䊡״ֲח➬鴥ךָוְ
ͦ͜Ͱٯసͷൃ ଓͷ͖͔͚ͬ Peer ͔Β Server ͚ͩͲɺ ੍ޚ Server ͔Β Peer
ʹ͢Δɻ ओैٯసͷൃ
Peer-Server-Room
ͦ͏͢Δͱ 1FFSכ31$؟٦غ٦؟٦ـ 1FFSכ31$؟٦غ٦؟٦ـ 4FSWFSכ1FFSדDSFBUF0FS㹋遤 4FSWFSכ1FFSדDSFBUF"OTXFS㹋遤
4FSWFSכ1FFSח"OTXFS床ׅ 31$ה⚺䖞鷞鯄ד⚺㼪埄床ֿׅהזֻ ء٦؛ٝءٍٕח11إحءّٝ然甧דֹ
݁Ռ ٗؽ٦הًحءُ然甧תד遤玎䏝 *TPNPQIJDַֿSQDָךתת籬ָ ぐ1FFSًحءُדאזּך 4FSWFS⩎דٕ٦ف穈ֽד0, 姻䌢ח然甧דֹ֮הכ11ד 4FSWFSכ8FC4PDLFUTⴖ倖ׅ
Web-UI ϑϩϯτΤϯυ (PQIFS+4欽ؿٗٝزؒٝسٓ؎ـٓٔ SFBDUٓ؎ؙ (P鎸鶢ד)5.-+4أة؎ٕ邌植 XBTN㼎䘔㨣תג
3D ϨϯμϦϯά three.js (PQIFS+4כKT项欵ָ⢪ִָծ 床ׅץֹ⦼ח♶⪒ָ֮ג 搀鋔׃ג劍䖉鸐חזזְ הְֲ⹛涸鎉铂ך㹀䒷ֹ鴥ד׃תֲ ຊ͜͜ Go ʹ͍ͨ͠
⹛ֻ״ֲחזגַוֲַַזְָ ಈ࡞σϞ https://gophertank.irieda.com
ڝ߹ͷϚονϯάʢϩϏʔʣ αʔόʔ (P㹋鄲ח״ٗؽ٦؟٦غ٦ך畸さ ֿחכ11؝طؙءّٝ堣腉כזְ ِ٦ؠ٦侧ח嫰⢽׃ג؟٦غ٦ٔا٦أؖٝؖٝ⢪ׯֲ (PPHMFכ㉀㡰涸חָ姻׃ְ ֿ⡚ٖ؎ذٝءֲגכְֽו11ָ剑䓼״יկ IUUQTHJUIVCDPNIFSPJDMBCTOBLBNB IUUQTHJUIVCDPN(PPHMF$MPVE1MBUGPSNPQFONBUDI
·ͱΊ GopherJS ༗ Vecty ༗ೳ Isomorphic ͍͍ͧ wasm ͷນ։͚͙ͦͩ͢͜ RTC
ηογϣϯʹ RPC ͱओैٯస͕༗ޮ Go ʹ WebGL αϙʔτϥΠϒϥϦ͕ཉ͍͠ P2P Ԇੑೳ͕࠷ڧ
(PQIFS+4ך㈓♧ך䓲挿כⰕ䒭ׄׯזַהֿ XBTN㼎䘔晛ָⰕ䒭ח《鴥ת זךד➙䖓כ㣐䩛䮶ג⢪ִ XBTNXFCSUDכװׅץגךًآٍ٦橆㞮ד⹛ֻ
͓ΘΓ