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
ebitenのマルチプレイ対応 | WebSocketの活用
Search
ponyo877
March 29, 2024
Technology
0
460
ebitenのマルチプレイ対応 | WebSocketの活用
【ゲーム開発/Go】Ebitengine ぷちConf #2【ゆるいLTと交流会】
https://gocon.connpass.com/event/306765/
ponyo877
March 29, 2024
Tweet
Share
More Decks by ponyo877
See All by ponyo877
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
580
Goのwasmで笑い男に挑戦してみた
ponyo877
1
120
GoのWasmでのWebRTC P2Pの検証+α
ponyo877
0
57
Ebitengineの1vs1ゲーム WebRTCの活用
ponyo877
0
510
GoのWasmでWebRTC P2Pで通信する
ponyo877
0
440
Other Decks in Technology
See All in Technology
Docker Desktop で Docker を始めよう
zembutsu
PRO
0
140
Alignment and Autonomy in Cybozu - 300人の開発組織でアラインメントと自律性を両立させるアジャイルな組織運営 / RSGT2025
ama_ch
1
2.3k
テストを書かないためのテスト/ Tests for not writing tests
sinsoku
1
170
KMP with Crashlytics
sansantech
PRO
0
220
Amazon Route 53, 待ちに待った TLSAレコードのサポート開始
kenichinakamura
0
120
20240522 - 躍遷創作理念 @ PicCollage Workshop
dpys
0
310
Oracle Base Database Service:サービス概要のご紹介
oracle4engineer
PRO
1
16k
【JAWS-UG大阪 reInvent reCap LT大会 サンバが始まったら強制終了】“1分”で初めてのソロ参戦reInventを数字で振り返りながら反省する
ttelltte
0
120
Godot Engineについて調べてみた
unsoluble_sugar
0
350
The future we create with our own MVV
matsukurou
0
1.9k
AWS Community Builderのススメ - みんなもCommunity Builderに応募しよう! -
smt7174
0
150
.NET AspireでAzure Functionsやクラウドリソースを統合する
tsubakimoto_s
0
180
Featured
See All Featured
Facilitating Awesome Meetings
lara
51
6.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.5k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Why Our Code Smells
bkeepers
PRO
335
57k
Into the Great Unknown - MozCon
thekraken
34
1.6k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
49k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
30
2.1k
The Power of CSS Pseudo Elements
geoffreycrofte
74
5.4k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Transcript
ۚ QPOZP FCJUFOͷϚϧνϓϨΠରԠ 8FC4PDLFUͷ׆༻
ϚϧνϓϨΠ w ϚϧνϓϨΠͱਓҎ্ͷϢʔβͰڠ ྗɾରઓ͢Δ༡ͼํ w FCJUFOͷطଘͷήʔϜγϯάϧϓϨΠͷ ͷ͕େ w zෳਓͰͷ௨৴zΛݟͤΔͨΊʹΩϟϥΫ λΛͬͨνϟοτΛ࡞
ϚϧνϓϨΠΛࢧ͑Δٕज़ w 8FC4PDLFU Σϒιέοτ w ΫϥΠΞϯτͱαʔόؒͰํ ʹϦΞϧλΠϜʹσʔλΛΓऔ Γ͢Δٕज़ Ҿ༻IUUQTTIVLBQJODPNJOGPHSBQIJD*5XFCTPDLFU
8FC4PDLFUY(P w ΫϥΠΞϯτͰ͋ΔFCJUFOͷଞʹ8FC4PDLFUαʔό͕ඞཁ w ΫϥΠΞϯτͱαʔό͕ͲͪΒ(PݴޠͰॻ͚ΔͷͰπʔϧϓϥΫςΟε ͕࠶ར༻Ͱ͖ɺΓସ͑ͷετϨε͕গͳ͍ w (PͷHPMMJSBXFCTPDLFU ˑL Ͱ؆୯ʹॻ͚Δ
w XBTNͩͱ্هͷQBDLBHFඇରԠ w σϞOIPPZSJPXFCTPDLFU ˑL Λ༻
σϞ w ൃදऀͱڠྗऀͷਓͰΩϟϥΫλʔͷҠಈϝοηʔδͷૹ৴Λͯ͠ΈΔ w ૢ࡞ͨ࣌͠ͷ$ISPNFσϕϩούʔπʔϧΛݟͯ8FC4PDLFU௨৴ΛΈͤΔ w ࠷ޙʹ63-Λڞ༗ɺདྷΕΔਓདྷͯΒ͏ αʔό͕ύϯΫ͢Δ͔
ॲཧͷྲྀΕ ೖࣨ ΫϥΠΞϯτ" ৽نೖࣨ 8FC4PDLFUαʔό ΫϥΠΞϯτ# ΫϥΠΞϯτ"ΑΓલʹೖࣨࡁΈ ೖࣨ ೖࣨड ৽Ϣʔβ
ࣗ ొ Ϣʔβొ ৽Ϣʔβొ ΫϥΠΞϯτʹೖࣨ ௨ طଘϢʔβ ϝοηʔ δཤྺऔಘ௨ طଘϢʔβ ϝοηʔ δཤྺొ อଘ ྖҬ ʹ͋ Δ ͷΛ ৗʹ ࠶ඳ ը อଘ ྖҬ ʹ͋ Δ ͷΛ ৗʹ ࠶ඳ ը %# %# ϒϥβͷ อଘྖҬ ϒϥβͷ อଘྖҬ Ϣʔβ*% ࠲ඪ Y Z ͖
ॲཧͷྲྀΕ ϝοηʔδૹ৴ ΫϥΠΞϯτ" ೖࣨࡁΈ 8FC4PDLFUαʔό ΫϥΠΞϯτ# ೖࣨࡁΈ ϝοηʔδΛૹ৴ ϝοηʔδड ϝοηʔδొ
ϝοηʔδ௨ ϝοηʔδ ࣗͷ ొ ϝοηʔδొ Ϣʔβ*% ϝοηʔδ %# ϒϥβͷ อଘྖҬ ϒϥβͷ อଘྖҬ อଘ ྖҬ ʹ͋ Δ ͷΛ ৗʹ ࠶ඳ ը อଘ ྖҬ ʹ͋ Δ ͷΛ ৗʹ ࠶ඳ ը ϝοηʔδͷ9࠲ඪൃݴΩϟϥΫλͷ9࠲ඪͱಉ͡ ϝοηʔδͷ:࠲ඪൃݴ࣌ࠁݱࡏ࣌ࠁΛͱʹܭࢉ ු͔ͼ্͕Δ෩
·ͱΊ w 8FC4PDLFUΛ͏͜ͱͰFCJUFOͰϚϧνϓϨΠήʔϜΛ࣮Ͱ͖Δ w ϚϧνϓϨΠήʔϜͱͦͷαʔόͷํΛ(PݴޠͰ؆୯ʹ࣮Ͱ͖Δ
c࣮ྫ FCJUFOΫϥΠΞϯτ w ը໘ͷૢ࡞͝ͱʹԿΛૹΔ͔ܾΊͯૹΔɺجຊతʹ(BNF6QEBUFͰ࣮ func (g *Game) Update() error {
// ΩϟϥΫλʔͷҠಈ if dir != entity.DirUnknown { x, y := g.characters[g.id].Point() g.wss.Send(entity.NewMessage("move", entity.NewMoveBody(g.id, x, y, dir))) } // ϝοηʔδͷૹ৴ if ebiten.IsKeyPressed(ebiten.KeyEnter) { text := g.textField.Text() g.textField.Clear() g.wss.Send(entity.NewMessage("say", entity.NewSayBody(g.id, text))) } return nil }
c࣮ྫ 8FC4PDLFUαʔό func readMessage(session *session, service socket.UseCase) { ɹ for
{ var mp presenter.MessagePresenter if err := session.Read(&mp); err != nil { return } switch mp.MessageType { // ΩϟϥΫλʔͷҠಈ ΩϟϥΫλʔͷ࠲ඪΛӬଓԽ case "move": u := entity.NewUser(mp.Body.ID, mp.Body.X, mp.Body.Y, entity.Dir(mp.Body. if err := service.UpdateUser(u); err != nil { return } body := entity.NewEnterBody(users) mp := presenter.NewMessagePresenter(entity.NewMessage("enter", body)) if err := session.Write(&mp); err != nil { return } continue } // ϝοηʔδͷૹ৴ ϝοηʔδͷ༰ΛӬଓԽ case "say": if err := service.AddMessage(mp.Unmarshal()); err != nil { return } // ΩϟϥΫλʔͷҠಈ or ϝοηʔδͷૹ৴ΛଞͷϢʔβʹൖ if err := service.Publish(mp.Unmarshal()); err != nil { return } } } w 8FCTPDLFUͷϦΫΤετ ͷ۠ΛಡΈऔΓɺ۠ ಛ༗ͷૢ࡞Λ࣮ࢪ w ͦͷޙɺଞϢʔβૢ࡞ ༰Λૹ৴