mirror of
https://github.com/jech/galene.git
synced 2024-11-09 18:25:58 +01:00
Fix joining in frontend documentation.
This commit is contained in:
parent
6fbdf0eab2
commit
221ed44538
1 changed files with 27 additions and 5 deletions
|
@ -54,23 +54,44 @@ callback indicates that a chat message has been posted to the group, and
|
||||||
`ondownstream` is called when the server pushes a stream to the client;
|
`ondownstream` is called when the server pushes a stream to the client;
|
||||||
see the section below about streams.
|
see the section below about streams.
|
||||||
|
|
||||||
You may now connect to the server.
|
You may now connect to the server:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
serverConnection.connect(`wss://${location.host}/ws`);
|
serverConnection.connect(`wss://${location.host}/ws`);
|
||||||
```
|
```
|
||||||
|
|
||||||
You typically join a group and request media in the `onconnected` callback:
|
You typically join a group in the `onconnected` callback:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
serverConnection.onconnected = function() {
|
serverConnection.onconnected = function() {
|
||||||
this.join(group, 'join', username, password);
|
this.join(group, 'join', username, password);
|
||||||
this.request({'':['audio','video']});
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
You should not attempt to push a stream to the server until it has granted
|
After the server has replied to the join request, the `onjoined` callback
|
||||||
you the `present` permission through the `onjoined` callback.
|
will trigger. There, you update your user interface and request incoming
|
||||||
|
streams:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
serverConnection.onjoined = function(kind, group, perms, status, message) {
|
||||||
|
switch(kind) {
|
||||||
|
case 'join':
|
||||||
|
this.request({'':['audio','video']});
|
||||||
|
// then update the UI, possibly taking perms.present into account
|
||||||
|
break;
|
||||||
|
case 'change':
|
||||||
|
// update the UI
|
||||||
|
break;
|
||||||
|
case 'redirect':
|
||||||
|
this.close();
|
||||||
|
document.location.href = message;
|
||||||
|
break;
|
||||||
|
case 'fail':
|
||||||
|
// display the friendly error message
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Sending and receiving chat messages
|
## Sending and receiving chat messages
|
||||||
|
|
||||||
|
@ -85,6 +106,7 @@ You receive chat messages in the `onchat` callback. The server may
|
||||||
request that you clear your chat window, in that case the `onclearchat`
|
request that you clear your chat window, in that case the `onclearchat`
|
||||||
callback will trigger.
|
callback will trigger.
|
||||||
|
|
||||||
|
|
||||||
## Other messages
|
## Other messages
|
||||||
|
|
||||||
The `usermessage` method of the `ServerConnection` is similar to the
|
The `usermessage` method of the `ServerConnection` is similar to the
|
||||||
|
|
Loading…
Reference in a new issue