Skip to content

Commit

Permalink
整理
Browse files Browse the repository at this point in the history
  • Loading branch information
voluntas committed Jan 10, 2025
1 parent 81401f7 commit 715277e
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 33 deletions.
8 changes: 6 additions & 2 deletions check_stereo/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ class SendonlyClient {
}

async connect(stream: MediaStream): Promise<void> {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = { access_token: jwt };
if (this.secretKey !== "") {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
}

const audioTrack = stream.getAudioTracks()[0];
if (!audioTrack) {
Expand Down
10 changes: 6 additions & 4 deletions check_stereo_multi/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ class SendonlyClient {
}

async connect(stream: MediaStream): Promise<void> {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
if (this.secretKey !== "") {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
}

const audioTrack = stream.getAudioTracks()[0];
if (!audioTrack) {
Expand Down
8 changes: 6 additions & 2 deletions messaging/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,12 @@ class SoraClient {
}

async connect(compress: boolean, header: boolean) {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = { access_token: jwt };
if (this.secretKey !== "") {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
}

// connect ボタンを無効にする
const connectButton = document.querySelector<HTMLButtonElement>("#connect");
Expand Down
8 changes: 6 additions & 2 deletions recvonly/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ class SoraClient {
}

async connect(): Promise<void> {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = { access_token: jwt };
if (this.secretKey !== "") {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
}

await this.connection.connect();
}
Expand Down
10 changes: 6 additions & 4 deletions replace_track/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ class SoraClient {
}

async connect() {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
if (this.secretKey !== "") {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
}

await this.connection.connect(this.stream);
const localVideo = document.querySelector<HTMLVideoElement>("#local-video");
Expand Down
10 changes: 6 additions & 4 deletions sendonly/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ class SoraClient {
}

async connect(stream: MediaStream): Promise<void> {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
if (this.secretKey !== "") {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
}

await this.connection.connect(stream);

Expand Down
10 changes: 6 additions & 4 deletions sendrecv/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ class SoraClient {
}

async connect(stream: MediaStream) {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
if (this.secretKey !== "") {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
}

await this.connection.connect(stream);
const localVideo = document.querySelector<HTMLVideoElement>("#local-video");
Expand Down
10 changes: 6 additions & 4 deletions simulcast/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ class SimulcastSendonlySoraClient {
}

async connect(stream: MediaStream) {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
if (this.secretKey !== "") {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
}

await this.connection.connect(stream);

Expand Down
10 changes: 6 additions & 4 deletions spotlight_sendrecv/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ class SoraClient {
}

async connect(stream: MediaStream) {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
if (this.secretKey !== "") {
const jwt = await generateJwt(this.channelId, this.secretKey);
this.connection.metadata = {
access_token: jwt,
};
}

await this.connection.connect(stream);

Expand Down
3 changes: 0 additions & 3 deletions src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ export const generateJwt = async (
channelId: string,
secretKey: string,
): Promise<string> => {
if (secretKey === "") {
return "";
}
const header = { alg: "HS256", typ: "JWT" };
return (
new jose.SignJWT({
Expand Down

0 comments on commit 715277e

Please sign in to comment.