Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Socket.IO Introduction
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
orisano
December 04, 2018
Technology
3.3k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Socket.IO Introduction
orisano
December 04, 2018
More Decks by orisano
See All by orisano
OSS Performance Tuning Tips
orisano
8
6.3k
Docker-Compose & BuildKit
orisano
4
1.1k
Container Build Talk
orisano
3
2.6k
dockerignore talk
orisano
2
7.4k
Better docker image+
orisano
6
6.8k
Profiling Go Application
orisano
11
8.2k
Multi-stage Builds Patterns & Practice
orisano
6
5.4k
better docker image
orisano
22
31k
the world of characters
orisano
8
1.5k
Other Decks in Technology
See All in Technology
2拠点SRE活動始めてみた | sogaoh's LT @ ホンマでっかSRE勉強会 #3
sogaoh
PRO
0
230
Vue で書く 空間コンピューティング、TresJS と WebXR を使ったXR デバイスのフロントエンド開発
hiranuma
0
150
eBPF 簡介 2026 版
shunghsiyu
0
140
Flutter Widget Previewerで始めるUIプレビューとVRTの自動化
sakusaku3939
0
190
1週間、Opus封印でお願いします
kintotechdev
1
430
re:Inventで、人生は変わったのか? / growth-builders-hub-1-reinvent-2026
mhrtech
2
190
視野はAIに、視座は人に / ai-for-breadth-humans-for-perspective
nkzn
6
2.7k
Copilot Coworkで「みのるん式」やってみた
minorun365
PRO
1
740
AIテスト自動化と評価駆動開発EDD
happysamurai294
0
130
Agent 活用環境の構築・運用のための AWS サービスのご紹介/agentcore-for-building-and-operating-agents
ren8k
1
310
Patterns in AI Driven Software Development
akosma
PRO
0
430
[re:Invent2026事前勉強会(有志開催)]続きは、ラスベガスの廊下で / continue-in-the-vegas-hallway
sh_fk2
0
480
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
290
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
So, you think you're a good person
axbom
PRO
2
2.2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
330
Paper Plane (Part 1)
katiecoart
PRO
2
12k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
340
We Have a Design System, Now What?
morganepeng
55
8.4k
Chasing Engaging Ingredients in Design
codingconduct
0
380
Darren the Foodie - Storyboard
khoart
PRO
4
4.1k
A Modern Web Designer's Workflow
chriscoyier
699
190k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Transcript
Socket.IOʹೖͨ͠ @orisano
Socket.IOͬͯΔਓ
Socket.IOͬͨ͜ͱ͋Δਓ
Socket.IOΕΔਓ
ΰʔϧ Socket.IO͕ΕΔΑ͏ʹͳΔ
ͦͦSocket.IOͱ
Socket.IO • FEATURING THE FASTEST AND MOST RELIABLE REAL-TIME ENGINE
• ૣͯ͘৴པͰ͖ΔϦΞϧλΠϜΤϯδϯ • ϦΞϧλΠϜͰํͷevent-basedͳ௨৴
Socket.IO • Node.jsͰ࣮͞Ε͍ͯΔ • ࠓversion 2.0 • ϒϥβͰϦΞϧλΠϜ௨৴ͳΒ͜Εͱ͍͏ • ΩϥʔΞϓϦͩͬͨ
Α͋͘Δޡղͱͯ͠ Socket.IO == WebSocket
Socket.IO !== WebSocket
Socket.IO • Ή͠ΖWebSocketͷରԠঢ়گ͕ѱ͔ͬͨ࣌ظ ʹಉ༷ͷ͜ͱΛ͢ΔͨΊͷͷͩͬͨ • TransportWebSocketͰͳͯ͘Α͍ • TransportEngine.IOͰநԽ͞Ε͍ͯΔ
Engine.IO • Socket.IOͷͨΊʹ࡞ΒΕͨRealtime Engine • ௨৴ϨΠϠʔ·Ͱ͔͠ݟͳ͍ • eventͱ͔ͦ͏͍͏ػೳଘࡏ͠ͳ͍
Engine.IO • WebSocket [packet] • Polling [payload] • XMLHttpRequest •
JSONP • MUST support three transport
8FC4PDLFU 9.-)UUQ3FRVFTU +40/1 &OHJOF*0 4PDLFU*0 #SPXTFS$MJFOU
͑ͬ໘ष͞ ࠓͷ࣌ WebSocketͰ͍͍Ͱ͠ΐ
https://blog.jxck.io/entries/ 2016-08-22/websocket- connectivity.html
·ͱΊ • RFCʹଇͬͨWebSocketIE11͔Β • Connection: UpgradeΛམͱ͢ϛυϧϘοΫε • HTTPͰ࣌ؒுΓͬͺͳ͠ͷίωΫγϣϯΛ ΔϛυϧϘοΫε
·ͱΊ • RFCʹଇͬͨWebSocketIE11͔Β • Connection: UpgradeΛམͱ͢ϛυϧϘοΫε • HTTPͰ࣌ؒுΓͬͺͳ͠ͷίωΫγϣϯΛ ΔϛυϧϘοΫε IEͬͯͳΜͰ͔͢ʁ
·ͱΊ • RFCʹଇͬͨWebSocketIE11͔Β • Connection: UpgradeΛམͱ͢ϛυϧϘοΫε • HTTPͰ࣌ؒுΓͬͺͳ͠ͷίωΫγϣϯΛ ΔϛυϧϘοΫε IEͬͯͳΜͰ͔͢ʁ
҉߸Խ͢Εͳ͍Ͱ͢. wssΛ͏.
·ͱΊ • RFCʹଇͬͨWebSocketIE11͔Β • Connection: UpgradeΛམͱ͢ϛυϧϘοΫε • HTTPͰ࣌ؒுΓͬͺͳ͠ͷίωΫγϣϯΛ ΔϛυϧϘοΫε IEͬͯͳΜͰ͔͢ʁ
҉߸Խ͢Εͳ͍Ͱ͢. wssΛ͏. Ͳ͏ʹͳΒͳ͍
·ͱΊ • ࣮ࡍͲͷఔଘࡏ͢Δͷ͔Θ͔Βͳ͍ • ͍ΜͨʔͶͬͱ͍͠ͷͰଞͷݪҼ͋Δ • ϦΞϧλΠϜ௨৴͕؊Ͱ͍ΖΜͳڥͷϢʔβ ʹͬͯΒ͍͍ͨ߹Socket.IO
େઢ͠·͕ͨ͠
Socket.IOΛΔʹ
8FC4PDLFU 9.-)UUQ3FRVFTU +40/1 &OHJOF*0 4PDLFU*0 #SPXTFS$MJFOU
ਓ͕ؒ WebSocketΔͷ “””͍͠”””
ͦΕΑΓ্ͷϨΠϠʔ ͱ͍͏͜ͱʹ͠·͢
8FC4PDLFU 9.-)UUQ3FRVFTU +40/1 &OHJOF*0 4PDLFU*0 #SPXTFS$MJFOU
·ͣEngine.IOΛΔ
Engine.IO • https://github.com/socketio/engine.io-protocol • ࠓrevision: 3 • ͘͢͝γϯϓϧͰ໋ྩ͕7छྨ͔͠ͳ͍ • <packet
type id>[data] ୯७ͳformat
Engine.IO • 0 open, αʔό͔Β࠷ॳʹૹΒΕͯ͘Δ • 1 close, அ͢Δͱ͖ʹૹΔ •
2 ping, ͪ͜Β͔ΒૹΔੜଘใࠂ • 3 pong, pingΛड͚औͬͨ࣌ʹαʔό͔Βฦͬͯ͘Δ • 4 message, σʔλΛૹड৴͢Δ࣌ʹ͏ • 5 upgrade, transportΛม͑Δ࣌ʹૹΔ • 6 noop, ͳʹ͠ͳ͍
git clone https://github.com/orisano/socketio-handson cd socketio-handson npm i npm run serve:eio
npm run conn:eio
Engine.IO • < 0******* // open • > 2 //
ping • < 3 // pong • > 4hello. engine.io // message • < 4reply:hello
͜ΕͰEngine.IOᘳ
͋ͱSocket.IO͕ΕΕ
Socket.IO • https://github.com/socketio/socket.io-protocol • ࠓrevision: 4 • ͘͢͝γϯϓϧͰ໋ྩ͕7छྨ͔͠ͳ͍ • formatͷৄࡉʹ͍ͭͯ͋·Γॻ͍ͯͳ͍
Socket.IO • socket.io-parserͷ࣮ΛݟΔ • <packet type id>[(attachments)-] [(namespace:/),][id][data] • ͏Μ,
simple
Socket.IO • 0 CONNECT, αʔό͔Β࠷ॳʹૹΒΕͯ͘Δ • 1 DISCONNECT, அ͢Δͱ͖ʹૹΔ •
2 EVENT, Πϕϯτ͕ى͖ͨ࣌ʹૹड৴͢Δ • 3 ACK,ಛఆͷύέοτʹରͯ͠ฦ৴͢Δ࣌ʹ͏ • 4 ERROR,Τϥʔ͕ى͖ͨ࣌ʹ͏ • 5 BINARY_EVENT, όΠφϦΛૹΔ࣌ͬͪ͜ • 6 BINARY_ACK, όΠφϦΛฦ࣌ͬͪ͢͜
npm run serve:sio npm run conn:sio
Socket.IO • > 0 // e:open • > 40 //
e:message s:connect • < 42[“message”,”hello”] // e:message s:event data • > 42[“reply”,”?hello”] // e:message s:event data • < 41 // e:message s:disconnect • < 42[“message”,”hello”] // e:message s:event data • < 40 // e:message s:connect • < 42[“message”,”hello”] // e:message s:event data • > 42[“reply”,”?hello”] // e:message s:event data
͜ΕͰSocket.IOᘳ
ͦͦ
ͳΜͰSocket.IOͷʁ
https://github.com/orisano/gomasio socket.io-clientͷgolang࣮Λ ࡞ͬͨͷͰએ