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
potatotips 5
Search
wasnot
March 12, 2014
Programming
77
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
potatotips 5
GCMがこなくて困る場合の対策案です
wasnot
March 12, 2014
More Decks by wasnot
See All by wasnot
ファッションへのAI活用事例
wasnot
1
120
Other Decks in Programming
See All in Programming
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
200
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
170
速習iPhone Duo対応
yuukiw00w
2
910
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
160
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
310
AHC070解法紹介
eijirou
0
150
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
280
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
510
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
19
19k
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
600
Vue Fes Japan 2026 タイムテーブル徹底解説
448jp
1
580
iOSDCのペンライトを自動制御したい!
akkeylab
0
280
Featured
See All Featured
Fireside Chat
paigeccino
43
4k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Site-Speed That Sticks
csswizardry
13
1.5k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
620
Discover your Explorer Soul
emna__ayadi
2
1.3k
How STYLIGHT went responsive
nonsquared
100
6.3k
Between Models and Reality
mayunak
4
470
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
270
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
390
The SEO identity crisis: Don't let AI make you average
varn
0
560
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
260
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
Transcript
GCM͕ಧ͔ͳͯ͘ࠔΔ @wasnot_aa #potatochips 5 2014/03/12
ࣗݾհ:@wasnot_aa • ϑϦʔϏοτגࣜձࣾ →ISPʁΫϥυʁܞଳʁ • AndroidྐྵҰ ͓खॊΒ͔ʹ͓ئ͍͠·͢
potatochips-5 • ਓͷհͰษڧʹ͖·ͨ͠ • @tomo_watanabe ಉ͡ձࣾɹAndroidͷઌഐ • @__gfx__ େֶͰαʔΫϧͷಉظ
freebit
ΞϓϦ SIM༻ସ ϫΠϠϨεϝσΟΞཧ(AirDroid, SnapPeaΆ͍) IPి
GCM͕ಧ͔ͳͯ͘ࠔΔ
͍·͞ΒGCMʁ • GCM: Google Cloud Messaging ศརͳ௨ػೳ(iOSͰ͍͏APNS) • ࣌ʑಧ͔ͳ͍orΕΔ •
ͪΌΜͱૹ৴Ͱ͖͔ͨΘ͔Βͳ͍ ͓Βͤૹ৴ʗಉظͳΒͳ͍ →IPిʗνϟοτܥͩͱؾʹͳΔʂ
ݪҼɿheartbeatͷִؒ • GTalk Service InfoͰ֬ೝ • Wi-Fiͩͱ15ɺ 3G/LTEͩͱ53 (ʹΑΓ28?) •
࠷େ53ಧ͔ͳ͍Մೳੑ
ରࡦ 1. ճઢͷNATςʔϒϧߋ৽සΛԼ͛Δ →ࣗࣾճઢରࡦࡁΈ 2. ͷHeartbeat IntervalΛॻ͖͑Δ →ॻ͖͑Մೳ͚ͩͲ(ex. PNF) 3.
GCMͲ͖Λ࡞ͬͯසΛ্͛Δ →Linefacebook͍ͬͯΔʁ
GCMͷαϙʔτ • GCMͷΑ͏ʹ࠷ݶͷଓΛҡ࣋͢Δ • ࣗͷΞϓϦ͚ͩʹ௨͢Δ →GCMͷΑ͏ʹεϩοτϦϯά͠ͳ͍ • ϝοηʔδΛετΞ͠ͳ͍ →ετΞGCMʹͤΔ
αʔό socketΛػͯ͠ ͭͳ͕ͬͨΒkeepalive ͯ͠Β͏͚ͩɺ Β͍͠ var net = require('net'); var
server = net.createServer( function(socket) { socket.write("welcome to KeepAlive\r\n"); socket.setTimeout(4*60*1000); // timeout settings 4MIN socket.setKeepAlive(true,1000 * 10); socket.on("data",function(data){ var str = data; if( str.toString().indexOf("ping") == 0 ){ socket.write("pong\r\n"); log.debug("client alive "); }else if( str.toString().indexOf('regist') == 0 ){ var name = // σόΠε໊ΛऔΓग़͢ // add new socket and name setClient(socket, name); setClientSocketName(socket, name); log.debug('REGIST='+name+":"+socket.remoteAddress); // ... // } }); }).listen(5228); →node.jsৄ͘͠ͳ͍͚Ͳ ɹखܰͦ͏ node.jsͩͱ͓खܰʁ
ΫϥΠΞϯτ Socket conn = new Socket(“192.168.0.3”, 5228); InputStream is =
conn.getInputStream(); OutputStream os = conn.getOutputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os)); String str; while ((str = reader.readLine()) != null) { // pong received if (str.startsWith("pong")) { // keepalive ޭ } // regist in nodejs memory else if (str.startsWith("welcome to ")) { // device໊Λొ writer.write("regist " + name); writer.flush(); // ... ࣌ʑkeepalive͢Δ .. // } // receive something else if (str.startsWith(“hogehoge”) { // message ड৴, దٓॲཧ͢Δ // ... // } } // close conn.close(); socketΛͭͳ͍Ͱ σόΠε໊ొ ࣌ʑkeepaliveͷΘΓʹ ۭϦΫΤετΛૹΔ Կ͔͖ͨΒॲཧ͢Δ →ৗறServiceΛ࡞Ε ɹͰ͖ͦ͏
ͦͷଞ • ΫϥΠΞϯτͷిফඅʹؾΛ͚ͭΔ →15ʹҰճఔͳΒͦΕ΄Ͳͳͦ͞͏ →NWସ࣌ͷॲཧ͕໘ͦ͏ • σόΠεIDηογϣϯͷཧ →࣮ࡍʹredisclusterΛ͔ͭͬͯ·͢
͋Γ͕ͱ͏͍͟͝·ͨ͠ αϯϓϧ android https://github.com/wasnot/android-notify node https://github.com/wasnot/node-notify-sample