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
Laravel5.5 Broadcastingを使ってみた話
Search
Akiyoshi Tanaka
November 15, 2017
Technology
1
490
Laravel5.5 Broadcastingを使ってみた話
laravel.osaka #12
https://github.com/akkunchoi/laravel-broadcasting-sample-app
Akiyoshi Tanaka
November 15, 2017
Tweet
Share
More Decks by Akiyoshi Tanaka
See All by Akiyoshi Tanaka
Node.jsサーバアプリケーションの 稼働方法 ~基本からDockerまで~
akkunchoi
1
800
TypeScript @Decorator で node.js 開発
akkunchoi
0
59
Other Decks in Technology
See All in Technology
オブザーバビリティの Primary Signals
onk
PRO
0
550
クラウドサインにおけるプロダクトマネージャーの役割と開発プロセス / 20240410_cloudsign-PdM
bengo4com
1
680
元インフラエンジニアに成る / Human Resources to Human Relations
bobtani
3
810
シン・Kafka / shin-kafka
oracle4engineer
PRO
7
2.7k
人間の尊厳、幸福、アクセシビリティ / 第116回「WEB TOUCH MEETING」アクセシビリティSP
nulabinc
PRO
2
180
Discord とビルダー&チャットボットの使い方 / How to use Discord and Builder & Chatbots
ks91
PRO
0
130
反実仮想機械学習とは何か
usaito
PRO
7
2.2k
**強い**エンジニアのなり方 - フィードバックサイクルを勝ち取る / grow one day each day
soudai
61
18k
LLM とプロンプトエンジニアリング/チューターをビルドする / LLM and Prompt Engineering and Building Tutors
ks91
PRO
0
220
小さな開発会社がWebサービスを作る理由
polidog
PRO
1
160
Janus
bkuhlmann
1
490
Algyan イベント振り返り
linyixian
0
190
Featured
See All Featured
5 minutes of I Can Smell Your CMS
philhawksworth
199
19k
Rebuilding a faster, lazier Slack
samanthasiow
72
8.2k
WebSockets: Embracing the real-time Web
robhawkes
59
7k
Fireside Chat
paigeccino
20
2.6k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
124
32k
Debugging Ruby Performance
tmm1
70
11k
Imperfection Machines: The Place of Print at Facebook
scottboms
258
12k
Fashionably flexible responsive web design (full day workshop)
malarkey
397
65k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
240
1.2M
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
Learning to Love Humans: Emotional Interface Design
aarron
266
39k
Art, The Web, and Tiny UX
lynnandtonic
288
19k
Transcript
Laravel BroadcastingΛͬͯΈͨ laravel.osaka #12 2017-11-15
͢͜ͱ - σϞΞϓϦ - https://github.com/akkunchoi/laravel-broadcasting-sample-app - Laravel Broadcasting ͷઃఆɾ࣮ -
ͬͯΈͯؾ͍ͨ
ࣗݾհ # ໊લ ాதষت / Akiyoshi TANAKA / @akkun_choi #
ॴଐ גࣜձࣾBTree / දऔక / ΤϯδχΞ # ܦྺ PHP(ZF) -> Rails -> node.js -> Laravel(ॳ৺ऀ)
Broadcasting - αʔόʔ͔ΒϢʔβʔʹϦΞϧλΠϜ௨ - WebSocketΛ͏ - Pusher or Socket.io͕༻ҙ͞Ε͍ͯΔ -
ࠓճPusherΛ༻͠·͢
ઃఆํ๏ - ϥΠϒϥϦΛΠϯετʔϧ - BroadcastServiceProviderΛՃ - Pusherઃఆ - .env -
config/broadcasting.php - resources/assets/js/bootstrap.js $ npm install --save laravel-echo pusher-js $ composer require pusher/pusher-php-server "~2.6"
ϒϩʔυΩϟετ͢Δ - ShouldBroadcastΛ࣮͢ΔΠϕϯτΛ࡞ - νϟϯωϧ͕2छྨ͋Δ - PrivateChannel - PresenceChannel (=
PrivateChannel + α) - event() or broadcast() ͰૹΔ broadcast(new UserUpdated($user))->toOthers(); 4IPVME#SPBEDBTUΠϕϯτ
ϒϩʔυΩϟετΛड͚औΔ - laravel-echo const channel = window.Echo.join('channel-name') .here((users) => {
console.log('I'm here'); }) .joining((user) => { console.log('joining user', user); }) .leaving((user) => { console.log('leaving user', user); }) .listen('UserUpdated', (e) => { participants.update(e.user); })
ཹҙ1: ೝূ - ೝূඞཁ - /broadcasting/auth ʹΞΫηε͢Δ - Auth::user() ͰϢʔβʔ͕औಘͰ͖Δඞཁ͕͋Δ
- ͦͷͨΊʹɺࣄલʹAuth::login()͕ඞཁ - PublicChannel͋Γ·ͤΜ - Pusherʹ͋Δ͚ͲɺLaravelʹͳ͍
ཹҙ2: broadcaster # Pusher - socket.ioΑΓָ - 100ಉ࣌ଓɺ200,000ϝοηʔδ/·Ͱແྉ - ड৴ͳ͍͕ɺૹ৴͕͍
- https://dashboard.pusher.com/ # socket.io - redisϫʔΧʔ͕ඞཁ - εέʔϥϏϦςΟ
ཹҙ3: ૹ৴͍ - ։ൃ༻ϏϧτΠϯαʔό - ϓϩηε1ͭͳͷͰɺେྔͷϦΫΤετࡹ͚ͳ͍ - ຊ൪WEBαʔόʔΛஔ͘͜ͱͰղܾ - Pusher
- ૹ৴ͯ͠৴͞ΕΔ·Ͱ1ඵఔ͔͔͍ͬͯΔ - ཁҼ: ௨৴ճ૿, HTTPS, keep aliveແ͠, αʔόʔ͕γϯΨϙʔϧ - ղܾࡦ: pusherͷૹ৴ํ๏Λ͢Δʁ
ͦͷଞ - ࿈ଧରࡦʹ lodash.throttle() this.throttlePost = _.throttle(() => { axios.post('/works',
{count: this.count}); }, 500);
·ͱΊ - BroadcastingΛͬͯσϞΞϓϦΛߏஙͨ͠ - PusherΛͬͯखܰʹϦΞϧλΠϜ௨͕Ͱ͖ͨ - ϦΞϧλΠϜੑΛߴΊΔͳΒɺ͏Ұख͍ؒΔ
։ൃϝϯόʔืूʂ - Laravel - node.js - socket.io - Vue /
React / angular - ۀҕୗɺϦϞʔτ։ൃ