You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/explanation/moq-with-fishjam.mdx
+20-11Lines changed: 20 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,42 +98,51 @@ Access to the relay is controlled by **MoQ tokens** — short-lived JWTs that ar
98
98
| Publisher token | Write access to a specific path | Streamer |
99
99
| Subscriber token | Read access to a path or namespace | Viewer |
100
100
101
-
A token is attached to the relay URL as a query parameter (`?jwt=<token>`). The relay validates the token and enforces its scope before allowing any media to flow.
101
+
A token is attached to the relay URL as a query parameter (`?jwt=<token>`). The relay validates the token and enforces its scope before allowing any media to flow. Both the Sandbox API and the Server SDK hand you the authenticated **connection URL** (the relay URL with the token already embedded), so the client can just take it as is and connect.
102
102
103
103
Keeping publisher and subscriber tokens separate ensures that a viewer can never accidentally publish to the stream, and a publisher cannot subscribe to paths it does not own.
104
104
105
-
## Getting Tokens
105
+
## Where to get the Connection URL from?
106
106
107
-
There are two ways to obtain MoQ tokens, depending on where you are in the development lifecycle.
107
+
There are two ways to obtain a MoQ connection URL, depending on where you are in the development lifecycle.
108
108
109
109
### Sandbox API (prototyping)
110
110
111
-
The **Sandbox API** is a ready-made backend provided by Fishjam for development and prototyping. It issues tokens without requiring you to build your own server, so you can start streaming immediately.
111
+
The **Sandbox API** is a ready-made backend provided by Fishjam for development and prototyping. It issues connection URLs without requiring you to build your own server, so you can start streaming immediately.
112
112
113
-
To get a publisher token, call:
113
+
To get a publisher connection URL, call:
114
114
115
115
```
116
116
GET https://fishjam.io/api/v1/connect/{FISHJAM_ID}/room-manager/moq/{PUBLISHER-PATH}/publisher
117
117
```
118
118
119
-
To get a subscriber token, call:
119
+
To get a subscriber connection URL, call:
120
120
121
121
```
122
122
GET https://fishjam.io/api/v1/connect/{FISHJAM_ID}/room-manager/moq/{SUBSCRIBER-PATH}/subscriber
123
123
```
124
124
125
+
To get a full-access connection URL — one that can both publish to and subscribe on the path — call:
126
+
127
+
```
128
+
GET https://fishjam.io/api/v1/connect/{FISHJAM_ID}/room-manager/moq/{PATH}/full-access
129
+
```
130
+
131
+
Each returns a JSON object with a `connection_url` field — the relay URL with the JWT embedded as `?jwt=` — alongside the raw `token`.
132
+
125
133
The Sandbox API is **not intended for production** — it has no authentication and is only available in the Sandbox environment. See [What is the Sandbox API?](./sandbox-api-concept) for more context.
126
134
127
135
### Fishjam Server SDK (production)
128
136
129
-
In production, your backend generates tokens using the **Fishjam Server SDK**. This gives you full control over who can publish and who can subscribe.
137
+
In production, your backend generates connection URLs using the **Fishjam Server SDK**. This gives you full control over who can publish and who can subscribe.
130
138
131
-
The SDK's `createMoqToken` method accepts either a `publishPath`or a `subscribePath`:
139
+
The SDK's `createMoqAccess` method accepts a `publishPath`, a `subscribePath`, or both, and returns the MoQ access details — a `connection_url` (the relay URL with the JWT embedded) alongside the raw `token`:
132
140
133
-
-`publishPath` — issues a publisher token scoped to that path.
134
-
-`subscribePath` — issues a subscriber token scoped to that path or namespace prefix.
141
+
-`publishPath` — returns a publisher connection URL scoped to that path.
142
+
-`subscribePath` — returns a subscriber connection URL scoped to that path or namespace prefix.
143
+
- both `publishPath` and `subscribePath` — returns a full-access connection URL that can publish and subscribe on those paths.
135
144
136
-
Your backend then delivers each token to the appropriate client (publisher or viewer), which uses it to connect to the relay.
145
+
Your backend then delivers each connection URL to the appropriate client (publisher or viewer), which uses it to connect to the relay.
137
146
138
147
See the [Web Publishing](../tutorials/moq/web-publishing) and [Web Subscribing](../tutorials/moq/web-subscribing) tutorials (or their [React Native](../tutorials/moq/react-native-publishing)[counterparts](../tutorials/moq/react-native-subscribing)) for working code examples.
Copy file name to clipboardExpand all lines: docs/tutorials/moq/react-native-publishing.mdx
+16-22Lines changed: 16 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,12 +47,12 @@ MoQ is a protocol with a well-defined negotiation, so a publisher and a subscrib
47
47
48
48
If you don't have a backend server set up, you can prototype publishing using the [Sandbox API](../../explanation/sandbox-api-concept).
49
49
50
-
### Obtaining a publisher token
50
+
### Obtaining a publisher connection URL
51
51
52
52
For more on what the Sandbox API is and its limitations, see [What is the Sandbox API?](../../explanation/sandbox-api-concept).
53
53
54
54
:::info
55
-
To obtain a MoQ token you'll need your Fishjam ID and Sandbox API URL. If you don't have them already, see [Sandbox API URL and Fishjam ID](../../explanation/sandbox-api-concept#sandbox-api-url-and-fishjam-id).
55
+
To obtain a MoQ connection URL you'll need your Sandbox API URL. If you don't have it already, see [Sandbox API URL](../../explanation/sandbox-api-concept#sandbox-api-url-and-fishjam-id).
56
56
:::
57
57
58
58
<TabsgroupId="sandbox-token">
@@ -64,17 +64,16 @@ To obtain a MoQ token you'll need your Fishjam ID and Sandbox API URL. If you do
const session =useSession(relayUrl, (s) =>s.connect());
121
+
// Open the MoQ session against the Fishjam relay using the publisher connection URL
122
+
const session =useSession(publishUrl, (s) =>s.connect());
129
123
const camera =useCamera({ position: "front" });
130
124
const microphone =useMicrophone();
131
125
const publisher =usePublisher(session);
@@ -174,7 +168,7 @@ The session owns the connection to the relay; the publisher reuses it. Because p
174
168
175
169
The [Quickstart](#quickstart-with-the-sandbox-api) gets you publishing quickly. In production, your backend generates tokens with proper authorization, so you control who can publish.
176
170
177
-
A **publisher token** grants write access to a specific path. Generate one on your backend and deliver it to the broadcasting client:
171
+
A **publisher connection URL** grants write access to a specific path. Generate one on your backend and deliver it to the broadcasting client:
178
172
179
173
<TabsgroupId="language">
180
174
<TabItemvalue="ts"label="TypeScript">
@@ -193,8 +187,8 @@ A **publisher token** grants write access to a specific path. Generate one on yo
193
187
194
188
const streamPath ='stream-alice';
195
189
196
-
// Generate a token that allows publishing to 'stream-alice'
Deliver this token to the mobile client, then use it to build the relay URL and connect as described in [Connecting and publishing](#connecting-and-publishing).
217
+
Deliver this connection URL to the mobile client, then use it to connect as described in [Connecting and publishing](#connecting-and-publishing).
Copy file name to clipboardExpand all lines: docs/tutorials/moq/react-native-subscribing.mdx
+27-36Lines changed: 27 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,12 +55,12 @@ If you don't have a backend server set up, you can prototype subscribing using t
55
55
MoQ is a protocol with a well-defined negotiation, so a publisher and a subscriber don't need to use the same client library. A stream published from the browser with [`@moq/publish`](./web-publishing) can be watched with `react-native-moq`, and vice versa.
56
56
:::
57
57
58
-
### Obtaining a subscriber token
58
+
### Obtaining a subscriber connection URL
59
59
60
60
For more on what the Sandbox API is and its limitations, see [What is the Sandbox API?](../../explanation/sandbox-api-concept).
61
61
62
62
:::info
63
-
To obtain a MoQ token you'll need your Fishjam ID and Sandbox API URL. If you don't have them already, see [Sandbox API URL and Fishjam ID](../../explanation/sandbox-api-concept#sandbox-api-url-and-fishjam-id).
63
+
To obtain a MoQ connection URL you'll need your Sandbox API URL. If you don't have it already, see [Sandbox API URL](../../explanation/sandbox-api-concept#sandbox-api-url-and-fishjam-id).
64
64
:::
65
65
66
66
<TabsgroupId="sandbox-token">
@@ -72,17 +72,16 @@ To obtain a MoQ token you'll need your Fishjam ID and Sandbox API URL. If you do
@@ -198,7 +192,7 @@ It exposes imperative `enterFullscreen()` / `exitFullscreen()` methods on its re
198
192
199
193
The [Quickstart](#quickstart-with-the-sandbox-api) gets you watching quickly. In production, your backend generates tokens with proper authorization, so you control who can subscribe.
200
194
201
-
A **subscriber token** grants read access to a specific path. Generate one on your backend and deliver it to the viewing client:
195
+
A **subscriber connection URL** grants read access to a specific path. Generate one on your backend and deliver it to the viewing client:
202
196
203
197
<TabsgroupId="language">
204
198
<TabItemvalue="ts"label="TypeScript">
@@ -217,8 +211,8 @@ A **subscriber token** grants read access to a specific path. Generate one on yo
217
211
218
212
const streamPath ='stream-alice';
219
213
220
-
// Generate a token that allows subscribing to 'stream-alice'
Deliver this token to the mobile client, then use it to build the relay URL and connect as described in [Connecting and subscribing](#connecting-and-subscribing).
241
+
Deliver this connection URL to the mobile client, then use it to connect as described in [Connecting and subscribing](#connecting-and-subscribing).
248
242
249
243
### Subscribe to a namespace
250
244
251
245
When multiple publishers join a room, you won't know their exact paths in advance.
252
246
Instead of consuming a single path, you can **discover** all broadcasts published under a namespace prefix and subscribe to each one as they appear.
253
247
254
-
To do this, generate a subscriber token scoped to the room namespace instead of a single stream path.
248
+
To do this, generate a subscriber connection URL scoped to the room namespace instead of a single stream path.
255
249
256
250
<TabsgroupId="language">
257
251
<TabItemvalue="ts"label="TypeScript">
@@ -267,16 +261,16 @@ To do this, generate a subscriber token scoped to the room namespace instead of
On the client, pass the namespace token's relay URL to `useSession`, then call `useBroadcasts(session, roomName)` with the room prefix. It returns a reactive `BroadcastInfo[]` that re-renders every time a publisher joins or leaves — no manual diffing of an announce set. Map over it to mount a player per broadcast:
306
+
On the client, pass the namespace connection URL to `useSession`, then call `useBroadcasts(session, roomName)` with the room prefix. It returns a reactive `BroadcastInfo[]` that re-renders every time a publisher joins or leaves — no manual diffing of an announce set. Map over it to mount a player per broadcast:
0 commit comments