プッシュ API¶
シグナリングで使用している WebSocket や DataChannel を活用できる API です。 この機能を使うことでアプリケーション側でプッシュの仕組みを用意する必要がなくなります。
PushChannel¶
- x-sora-target:
Sora_20160711.PushChannel
指定したチャネル全員にプッシュ通知を送る。
キー |
型 |
---|---|
channel_id |
string |
data |
object |
data には全員に通知する値 (JSON object) を指定してください。 クライアントには data に指定した値 (JSON object) が送られます。
$ http POST 127.0.0.1:3000/ \
x-sora-target:Sora_20160711.PushChannel \
channel_id=sora \
data:="{\"spam\": \"egg\"}" \
-vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 47
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushChannel
{
"channel_id": "sora",
"data": {
"spam": "egg"
}
}
HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 06:26:21 GMT
server: Cowboy
{
"data": {
"spam": "egg"
},
"type": "push"
}
PushClient¶
- x-sora-target:
Sora_20160711.PushClient
指定したチャネルのクライアントにプッシュ通知を送ります。
キー |
型 |
---|---|
channel_id |
string |
client_id |
string |
data |
object |
複数の接続に同一の client_id
が指定されていた場合、複数の接続にプッシュ通知が送られます。
$ http POST 127.0.0.1:3000/ \
x-sora-target:Sora_20160711.PushClient \
channel_id=sora \
client_id=C0YTCRZM715BKATBXWFPKTYGRM \
data:="{\"spam\": \"egg\"}" \
-vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 100
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushClient
{
"channel_id": "sora",
"client_id": "C0YTCRZM715BKATBXWFPKTYGRM",
"data": {
"spam": "egg"
}
}
HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 07:46:31 GMT
server: Cowboy
{
"data": {
"spam": "egg"
},
"type": "push"
}
PushConnection¶
- x-sora-target:
Sora_20160711.PushConnection
指定したチャネルの接続にプッシュ通知を送ります。
キー |
型 |
---|---|
channel_id |
string |
connection_id |
string |
data |
object |
$ http POST 127.0.0.1:3000/ \
x-sora-target:Sora_20160711.PushConnection \
channel_id=sora \
connection_id=C0YTCRZM715BKATBXWFPKTYGRM \
data:="{\"spam\": \"egg\"}" \
-vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 100
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushConnection
{
"channel_id": "sora",
"connection_id": "C0YTCRZM715BKATBXWFPKTYGRM",
"data": {
"spam": "egg"
}
}
HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 07:46:31 GMT
server: Cowboy
{
"data": {
"spam": "egg"
},
"type": "push"
}
PushChannelByRole¶
- x-sora-target:
Sora_20201120.PushChannelByRole
指定したチャネルの指定したロールにプッシュ通知を送ります。
キー |
型 |
---|---|
channel_id |
string |
role |
string (sendrecv | sendonly | recvonly) |
data |
object |
$ http POST 127.0.0.1:3000/ \
x-sora-target:Sora_20201120.PushChannelByRole \
channel_id=sora \
role=sendrecv \
data:="{\"spam\": \"egg\"}" \
-vvv
POST / HTTP/1.1
Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 67
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/2.2.0
x-sora-target: Sora_20201120.PushChannelByRole
{
"channel_id": "sora",
"data": {
"spam": "egg"
},
"role": "sendrecv"
}
HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 37
content-type: application/json
date: Thu, 03 Dec 2020 06:16:16 GMT
server: Cowboy
{
"data": {
"spam": "egg"
},
"type": "push"
}