
開発環境
- AWS API Gateway(WebSocket)
connectionIdのマッピング方法
aws apigatewayv2 update-integration \
--integration-id [Integration ID] \
--api-id [API ID] \
--request-parameters 'integration.request.header.connectionId'='context.connectionId'
conenctionIdとは
webSocektに接続したときに発行される一意なID
双方向通信をするときに必要なIDです。
WebSocketに接続したときに、入場券のイメージで発行されます。

1対nでチャットのようにメッセージを送りたい場合、WebSocketはconnectionIdを持っている人にメッセージを送ります。

connectionIdで個人を特定して送ることもできます。

connectionIdでオンライン状態を判断することもできます.

WebSocketから切断されるとconnectionIdは削除されます。

API Gatewayについての記事
このサイトでは、AWSのAPI GatewayでwebsocketをPHPで実装した経験から、
躓くポイントやその対応方法を解説しています。
ぜひ参考にしてみてください!