iOS VoIP待ち受けの仕組み
-
Upload
typester -
Category
Entertainment & Humor
-
view
7.232 -
download
1
Transcript of iOS VoIP待ち受けの仕組み
![Page 1: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/1.jpg)
IP電話待ち受けの秘密
![Page 2: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/2.jpg)
About me•Daisuke Murase• Software engineer in KAYAC Inc.• #Perl #C #C++ #Objective-C #JavaScript #CoffeeScript #ActionScript
![Page 3: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/3.jpg)
About me
•新規開発ラボ BM11チーム所属
![Page 4: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/4.jpg)
About me
•新規開発ラボ BM11チーム所属•最近の仕事• Reengo(Facebook電話)• VQチェッカー(モテ声診断)
![Page 5: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/5.jpg)
About me• a.k.a typester• http://github.com/typester• http://search.cpan.org/~typester• http://twitter.com/typester• http://facebook.com/typester
![Page 6: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/6.jpg)
Agenda
• Reengoの紹介• iOSバックグラウンド動作のおさらい• iOSバックグラウンド待ち受けの仕組み• iOSバックグラウンド待ち受けの実装
![Page 8: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/8.jpg)
Reengo実装周り
![Page 9: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/9.jpg)
Reengo実装周り
• 適材適所の技術を採用
![Page 10: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/10.jpg)
Reengo実装周り
• 適材適所の技術を採用• ロジック、通信周りは C (iOS/Android共通)
![Page 11: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/11.jpg)
Reengo実装周り
• 適材適所の技術を採用• ロジック、通信周りは C (iOS/Android共通)• UI は Objective-C、Java
![Page 12: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/12.jpg)
Reengo実装周り
• 適材適所の技術を採用• ロジック、通信周りは C (iOS/Android共通)• UI は Objective-C、Java• サーバーサイドは Perl、Node.js
![Page 13: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/13.jpg)
iOSバックグラウンド動作のおさらい
![Page 14: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/14.jpg)
iOSバックグラウンド動作のおさらい
• バックグラウンド動作は最大10分間
![Page 15: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/15.jpg)
iOSバックグラウンド動作のおさらい
• バックグラウンド動作は最大10分間• 例外• オーディオ再生• 位置情報の取得• VoIP待ち受け
![Page 16: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/16.jpg)
iOSバックグラウンド動作のおさらい
• バックグラウンド動作は最大10分間• Info.plistのUIBackgroundModes• audio• location• voip
![Page 17: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/17.jpg)
iOSバックグラウンド動作のおさらい
• バックグラウンド動作は最大10分間• Info.plistのUIBackgroundModes• audio• location• voip
![Page 18: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/18.jpg)
バックグラウンドVoIP待ち受け
![Page 19: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/19.jpg)
バックグラウンドVoIP待ち受け
1. 待ち受け用のソケットをつくる
2. そのソケットに対しVoIPフラグを立てる
3. そのソケットはiOSが管理を代行してくれる
4. KeepAliveハンドラで接続をチェック
![Page 20: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/20.jpg)
VoIPフラグ?
それぞれのクラスにフラグを立てるメソッドが存在する
• NSInputStream、NSOutputStream• NSURLRequest• CFReadStreamRef、CFWriteStreamRef
![Page 21: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/21.jpg)
VoIPフラグ?
[stream setProperty:NSStreamNetworkServiceTypeVoIP forKey:NSStreamNetworkServiceType];
![Page 22: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/22.jpg)
KeepAliveハンドラ
UIApplicationのsetKeepAliveTimeout:handler:で登録
[[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ // ここで接続を確認 }];
![Page 23: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/23.jpg)
KeepAliveハンドラ
UIApplicationのsetKeepAliveTimeout:handler:で登録
[[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ // ここで接続を確認 }];
![Page 24: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/24.jpg)
KeepAliveハンドラ
UIApplicationのsetKeepAliveTimeout:handler:で登録
[[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ // ここで接続を確認 }];
![Page 25: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/25.jpg)
Cでロジック書いてたらどうすんの?
![Page 26: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/26.jpg)
Cでロジック書いてたらどうすんの?CFStreamCreatePairWithSocketでファイルディスクリプタからNSStreamを作ることができる
![Page 27: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/27.jpg)
Cでロジック書いてたらどうすんの?CFStreamCreatePairWithSocketでファイルディスクリプタからNSStreamを作ることができる
int fd = socket(AF_INET, SOCK_STREAM, 0);
NSInputStream* stream; CFStreamCreatePairWithSocket( kCFAllocatorDefault, fd, (CFReadStreamRef*)&stream, NULL);
![Page 28: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/28.jpg)
Cでロジック書いてたらどうすんの?CFStreamCreatePairWithSocketでファイルディスクリプタからNSStreamを作ることができる
int fd = socket(AF_INET, SOCK_STREAM, 0);
NSInputStream* stream; CFStreamCreatePairWithSocket( kCFAllocatorDefault, fd, (CFReadStreamRef*)&stream, NULL);
![Page 29: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/29.jpg)
待ち受けサンプル実装http://github.com/typester/voip-socket-test
•付属のserver.plが待ち受けサーバー•AppDelegate.mの #define HOST とかを自分のサーバーアドレスに変更
•アプリ立ち上げて、サーバーのSTDINに何か入力するとその内容がローカルPush通知される
•http://unknownplace.org/memo/2011/01/28/1/
![Page 30: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/30.jpg)
![Page 31: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/31.jpg)
デモ
![Page 32: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/32.jpg)
![Page 33: iOS VoIP待ち受けの仕組み](https://reader034.fdocument.pub/reader034/viewer/2022050907/557cfa09d8b42a071b8b4baa/html5/thumbnails/33.jpg)
完