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
520
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
870
TypeScript @Decorator で node.js 開発
akkunchoi
0
61
Other Decks in Technology
See All in Technology
AGIについてChatGPTに聞いてみた
blueb
0
130
Engineer Career Talk
lycorp_recruit_jp
0
190
SSMRunbook作成の勘所_20241120
koichiotomo
3
170
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
230
Taming you application's environments
salaboy
0
200
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
210
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
10
1.3k
Flutterによる 効率的なAndroid・iOS・Webアプリケーション開発の事例
recruitengineers
PRO
0
120
テストコード品質を高めるためにMutation Testingライブラリ・Strykerを実戦導入してみた話
ysknsid25
7
2.7k
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.4k
AIチャットボット開発への生成AI活用
ryomrt
0
170
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
29
13k
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
693
190k
Embracing the Ebb and Flow
colly
84
4.5k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
It's Worth the Effort
3n
183
27k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
A Tale of Four Properties
chriscoyier
156
23k
Making Projects Easy
brettharned
115
5.9k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
The Pragmatic Product Professional
lauravandoore
31
6.3k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
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 - ۀҕୗɺϦϞʔτ։ൃ