LoginSignup
11
4

More than 3 years have passed since last update.

目的

ほぼリモートになり、頻繁に使うようになったリアルタイム通信
どういった経緯で、そうなったのか歴史を見つつ、今は何を使ったら良いのか
ほぼ参考になったサイトのメモですが、時系列っぽく順にまとめております。

ポーリング

基本的にAjaxでURL単位にサーバへリクエストを送り、レスポンスを確認する
サーバ側にリクエストをしてデータを取ってくる
ヘッダーとか余計な通信があって効率が悪い

SSE

Server-sent events
サーバーからクライアントへの単一方向通信
https://en.wikipedia.org/wiki/Server-sent_events

SPDY(HTTP/2)

Googleが提唱、後のHTTP/2
ヘッダーの圧縮、不要な部分を削除
サーバプッシュ通信なのでサーバからクライアントへ送信できる
https://ja.wikipedia.org/wiki/SPDY
https://builder.japan.zdnet.com/html-css/35013644/

WebSocket

クライアント側からもサーバ側からも送信できる、双方向通信
ヘッダーが不要
https://ja.wikipedia.org/wiki/WebSocket
https://www.slideshare.net/mawarimichi/websocketwebrtc

Socket.IO

WebSocketが対応していないブラウザでも対応する
WebSocketとの違い

WebSocketとSocket.IOをherokuで動かす

触ってみました
https://devcenter.heroku.com/ja/articles/node-websockets

WebRTC

P2P通信
MediaCaptureでカメラやマイクの入力ができる
WebでRTC通信を行う仕様郡
https://ja.wikipedia.org/wiki/WebRTC
https://www.slideshare.net/mawarimichi/websocketwebrtc

おまけ

WebSocketはHTTP/2に置き換わるのか??

HTTP/2 では SSEを使って実装するのがよい?
https://www.infoq.com/articles/websocket-and-http2-coexist/
https://stackoverflow.com/questions/28582935/does-http-2-make-websockets-obsolete

FirebaseとSocket.IOの違い

FirebaseはGoogleが提供するサービスで実装なのでその範囲内で実装できる(有料だが責任が少なくなる)
Socket.IOは詳細に実装ができる(無料だが責任が大きくなる)
https://stackoverflow.com/questions/28676586/what-is-the-difference-between-socket-io-and-firebase

まとめ

テキストでのやり取り、共同編集については Firestoreだけあれば良さそう
ビデオや音声の入力が必要だと追加でWebRTCを利用する必要がありそう
ここはもう少しまとめます

11
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
4