Skip to content

Commit

Permalink
コード整理
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Jan 11, 2025
1 parent ad5bdce commit db67569
Show file tree
Hide file tree
Showing 22 changed files with 395 additions and 454 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-24.04
strategy:
matrix:
node: ["20", "22", "23"]
node: ["20"]
# browser: ["chromium", "firefox", "webkit"]
browser: ["chromium"]
env:
Expand All @@ -32,7 +32,6 @@ jobs:
with:
node-version: ${{ matrix.node }}
- uses: pnpm/action-setup@v4
- run: pnpm --version
- run: pnpm install
- run: pnpm exec playwright install ${{ matrix.browser }} --with-deps
- run: pnpm exec playwright test --project=${{ matrix.browser }}
Expand All @@ -51,7 +50,6 @@ jobs:
# if: success()
# steps:
# - name: Slack Notification
# if: success()
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_CHANNEL: sora-js-sdk
Expand All @@ -65,7 +63,6 @@ jobs:
if: failure()
steps:
- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: sora-js-sdk
Expand Down
1 change: 1 addition & 0 deletions check_stereo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<head>
<meta charset="utf-8">
<link rel="icon" href="data:,">
<title>Stereo Check シンプルサンプル</title>

<style>
Expand Down
33 changes: 10 additions & 23 deletions check_stereo/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,13 @@ document.addEventListener("DOMContentLoaded", async () => {
const channelIdSuffix = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX;
const secretKey = import.meta.env.VITE_SECRET_KEY;

// Sora クライアントの初期化
const sendonly = new SendonlyClient(
signalingUrl,
channelIdPrefix,
channelIdSuffix,
secretKey,
);
// URL から channelName パラメータを取得
const urlParams = new URLSearchParams(window.location.search);
const channelName = urlParams.get("channelName") || "";
const channelId = `${channelIdPrefix}:${channelName}:${channelIdSuffix}`;

const recvonly = new RecvonlyClient(
signalingUrl,
channelIdPrefix,
channelIdSuffix,
secretKey,
);
const sendonly = new SendonlyClient(signalingUrl, channelId, secretKey);
const recvonly = new RecvonlyClient(signalingUrl, channelId, secretKey);

// デバイスリストの取得と設定
await updateDeviceLists();
Expand Down Expand Up @@ -106,12 +99,11 @@ class SendonlyClient {

constructor(
signalingUrl: string,
channelIdPrefix: string,
channelIdSuffix: string,
channelId: string,
secretKey: string,
options: ConnectionOptions = {},
) {
this.channelId = `${channelIdPrefix}:check_stereo:${channelIdSuffix}`;
this.channelId = channelId;
this.secretKey = secretKey;
this.options = options;

Expand Down Expand Up @@ -338,13 +330,8 @@ class RecvonlyClient {
private canvas: HTMLCanvasElement | null = null;
private canvasCtx: CanvasRenderingContext2D | null = null;

constructor(
signalingUrl: string,
channelIdPrefix: string,
channelIdSuffix: string,
secretKey: string,
) {
this.channelId = `${channelIdPrefix}:check_stereo:${channelIdSuffix}`;
constructor(signalingUrl: string, channelId: string, secretKey: string) {
this.channelId = channelId;
this.secretKey = secretKey;

this.sora = Sora.connection(signalingUrl, this.debug);
Expand Down
1 change: 1 addition & 0 deletions check_stereo_multi/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<head>
<meta charset="utf-8">
<link rel="icon" href="data:,">
<title>Stereo Check マルチサンプル</title>

<style>
Expand Down
54 changes: 18 additions & 36 deletions check_stereo_multi/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,20 @@ document.addEventListener("DOMContentLoaded", async () => {
const channelIdSuffix = import.meta.env.VITE_SORA_CHANNEL_ID_SUFFIX;
const secretKey = import.meta.env.VITE_SECRET_KEY;

// Sora クライアントの初期化
const sendonly1 = new SendonlyClient(
signalingUrl,
channelIdPrefix,
channelIdSuffix,
secretKey,
{
clientId: "1",
},
);
const sendonly2 = new SendonlyClient(
signalingUrl,
channelIdPrefix,
channelIdSuffix,
secretKey,
{
clientId: "2",
},
);

const recvonly = new RecvonlyClient(
signalingUrl,
channelIdPrefix,
channelIdSuffix,
secretKey,
);
// URL から channelName パラメータを取得
const urlParams = new URLSearchParams(window.location.search);
const channelName = urlParams.get("channelName") || "";
const channelId = `${channelIdPrefix}:${channelName}:${channelIdSuffix}`;

const sendonly1 = new SendonlyClient(signalingUrl, channelId, secretKey, {
clientId: "1",
});

const sendonly2 = new SendonlyClient(signalingUrl, channelId, secretKey, {
clientId: "2",
});

const recvonly = new RecvonlyClient(signalingUrl, channelId, secretKey);

// デバイスリストの取得と設定
await updateDeviceLists();
Expand Down Expand Up @@ -143,12 +131,11 @@ class SendonlyClient {

constructor(
signalingUrl: string,
channelIdPrefix: string,
channelIdSuffix: string,
channelId: string,
secretKey: string,
options: ConnectionOptions = {},
) {
this.channelId = `${channelIdPrefix}:check_stereo_multi:${channelIdSuffix}`;
this.channelId = channelId;
this.secretKey = secretKey;
this.options = options;

Expand Down Expand Up @@ -375,13 +362,8 @@ class RecvonlyClient {
private canvases = new Map<string, HTMLCanvasElement>();
private canvasCtxs = new Map<string, CanvasRenderingContext2D | null>();

constructor(
signalingUrl: string,
channelIdPrefix: string,
channelIdSuffix: string,
secretKey: string,
) {
this.channelId = `${channelIdPrefix}:check_stereo_multi:${channelIdSuffix}`;
constructor(signalingUrl: string, channelId: string, secretKey: string) {
this.channelId = channelId;
this.secretKey = secretKey;

this.options = {};
Expand Down
16 changes: 10 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@

<body>
<div class="container">
<h2>基本</h2>
<ul>
<li><a href="/sendrecv/">送受信サンプル</a></li>
<li><a href="/sendonly/">送信サンプル</a></li>
<li><a href="/recvonly/">受信サンプル</a></li>
<li><a href="/spotlight_sendrecv/">スポットライト送受信サンプル</a></li>
<li><a href="/simulcast/">サイマルキャストサンプル</a></li>
<li><a href="/messaging/">メッセージングサンプル</a></li>
</ul>
<h2>その他</h2>
<ul>
<li><a href="/sendrecv/">配信視聴サンプル</a></li>
<li><a href="/sendonly/">配信サンプル</a></li>
<li><a href="/recvonly/">視聴サンプル</a></li>
<li><a href="/check_stereo/">ステレオチェックシンプルサンプル</a></li>
<li><a href="/check_stereo_multi/">ステレオチェックマルチサンプル</a></li>
<li><a href="/replace_track/">track 入れ替えサンプル</a></li>
<li><a href="/spotlight_sendrecv/">スポットライト配信視聴サンプル</a></li>
<li><a href="/simulcast/">サイマルキャスト配信/視聴サンプル</a></li>
<li><a href="/messaging/">メッセージングサンプル</a></li>
</ul>
</div>
</body>
Expand Down
29 changes: 20 additions & 9 deletions messaging/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@

<head>
<meta charset="utf-8">
<link rel="icon" href="data:,">
<title>リアルタイムメッセージングサンプル</title>
</head>

<body>
<div class="container">
<h1>リアルタイムメッセージングサンプル</h1>
<p>複数のブラウザで開いて sendMessage することで動作確認できます</p>
<h2>sora-js-sdk version: <span id="sora-js-sdk-version"></span></h2>
<label for="channel-name">チャンネル名:</label>
<input type="text" id="channel-name" name="channel-name" value="messaging"><br>
<div id="connection-id"></div>
<p>
<button id="connect">connect</button>
<button id="disconnect" disabled>disconnect</button>
<button id="get-stats">getStats</button><br />
</p>
<p>
<span>channel_id:</span>
<span id="channel-id"></span>
<br />
<span>session_id:</span>
<span id="session-id"></span>
<br />
<span>connection_id:</span>
<span id="connection-id"></span>
</p>
<div style="display: flex;">
<input type="text" name="message" />
<button id="send-message" disabled>sendMessage</button><br />
Expand All @@ -25,9 +37,6 @@ <h2>sora-js-sdk version: <span id="sora-js-sdk-version"></span></h2>
<input type="checkbox" id="check-header" />
<label for="check-header">Header</label>
</div>
<button id="connect">connect</button>
<button id="disconnect" disabled>disconnect</button>
<button id="get-stats">getStats</button><br />
<div>
<h3>messaging</h3>
<ul id="messaging">
Expand All @@ -38,8 +47,10 @@ <h3>messages</h3>
<ul id="received-messages">
</ul>
</div>
<div id="stats-report" style="white-space: pre-wrap; font-family: monospace;"></div>
<div id="stats-report-json"></div>
<p>
<button id="get-stats">getStats</button>
<pre id="stats-report-json"></pre>
</p>
</div>

<script type="module" src="./main.ts"></script>
Expand Down
Loading

0 comments on commit db67569

Please sign in to comment.