Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fishjam-web-sdk",
"version": "0.28.0",
"version": "0.28.2",
"license": "MIT",
"private": true,
"workspaces": [
Expand Down
2 changes: 1 addition & 1 deletion packages/mobile-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fishjam-cloud/react-native-client",
"version": "0.28.0",
"version": "0.28.2",
"description": "React Native client library for Fishjam",
"license": "Apache-2.0",
"author": "Fishjam Team",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fishjam-cloud/react-client",
"version": "0.28.0",
"version": "0.28.2",
Comment thread
Karolk99 marked this conversation as resolved.
"description": "React client library for Fishjam",
"license": "Apache-2.0",
"author": "Fishjam Team",
Expand Down
36 changes: 23 additions & 13 deletions packages/react-client/src/hooks/useSandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ type RoomManagerResponse = {
peer: BasicInfo;
};

type MoqAccessResponse = {
connection_url: string;
token: string;
};

export type MoqAccess = {
connectionUrl: string;
token: string;
};

export type UseSandboxProps = {
sandboxApiUrl: string;
};
Expand Down Expand Up @@ -79,36 +89,36 @@ export const useSandbox = (props: UseSandboxProps) => {
[sandboxApiUrl],
);

const fetchMoqToken = useCallback(
async (streamName: string, type: "subscriber" | "publisher") => {
const fetchMoqAccess = useCallback(
async (streamName: string, type: "subscriber" | "publisher"): Promise<MoqAccess> => {
if (!sandboxApiUrl) throw new MissingSandboxApiUrlError();

const urlEncodedStreamName = encodeURIComponent(streamName);

const res = await fetch(`${sandboxApiUrl}/moq/${urlEncodedStreamName}/${type}`);
if (!res.ok) throw new Error(`Failed to retrieve MoQ ${type} token for stream '${streamName}'.`);
if (!res.ok) throw new Error(`Failed to retrieve MoQ ${type} connection for stream '${streamName}'.`);

const data: { token: string } = await res.json();
return data.token;
const data: MoqAccessResponse = await res.json();
return { connectionUrl: data.connection_url, token: data.token };
},
[sandboxApiUrl],
);

const getSandboxMoqPublisherToken = useCallback(
async (streamName: string) => fetchMoqToken(streamName, "publisher"),
[fetchMoqToken],
const getSandboxMoqPublisherAccess = useCallback(
async (streamName: string) => fetchMoqAccess(streamName, "publisher"),
[fetchMoqAccess],
);

const getSandboxMoqSubscriberToken = useCallback(
async (streamName: string) => fetchMoqToken(streamName, "subscriber"),
[fetchMoqToken],
const getSandboxMoqSubscriberAccess = useCallback(
async (streamName: string) => fetchMoqAccess(streamName, "subscriber"),
[fetchMoqAccess],
);
Comment thread
Karolk99 marked this conversation as resolved.

return {
getSandboxPeerToken,
getSandboxViewerToken,
getSandboxLivestream,
getSandboxMoqPublisherToken,
getSandboxMoqSubscriberToken,
getSandboxMoqPublisherAccess,
getSandboxMoqSubscriberAccess,
};
};
2 changes: 1 addition & 1 deletion packages/react-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export {
type UseLivestreamViewerResult,
} from "./hooks/useLivestreamViewer";
export { type PeerWithTracks, usePeers } from "./hooks/usePeers";
export { type RoomType, useSandbox, type UseSandboxProps } from "./hooks/useSandbox";
export { type MoqAccess, type RoomType, useSandbox, type UseSandboxProps } from "./hooks/useSandbox";
export { useScreenShare } from "./hooks/useScreenShare";
export { useUpdatePeerMetadata } from "./hooks/useUpdatePeerMetadata";
export { useVAD } from "./hooks/useVAD";
Expand Down
2 changes: 1 addition & 1 deletion packages/ts-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fishjam-cloud/ts-client",
"version": "0.28.0",
"version": "0.28.2",
"description": "Typescript client library for Fishjam",
"license": "Apache-2.0",
"author": "Fishjam Team",
Expand Down
2 changes: 1 addition & 1 deletion packages/webrtc-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fishjam-cloud/webrtc-client",
"version": "0.28.0",
"version": "0.28.2",
"description": "Typescript client library for ExWebRTC/WebRTC endpoint in Membrane RTC Engine",
"license": "Apache-2.0",
"author": "Fishjam Team",
Expand Down
Loading