Add ability to set initial user status.

Setting the status after joining (using the "setstatus" action)
may cause multiple "user" messages to be sent to clients.  Add
the ability to set the initial status at join time.
This commit is contained in:
Juliusz Chroboczek
2022-01-25 18:16:42 +01:00
parent 0b5e40bc7f
commit 710cc3cc14
3 changed files with 21 additions and 5 deletions
+7 -3
View File
@@ -416,15 +416,19 @@ ServerConnection.prototype.connect = async function(url) {
* @param {string} group - The name of the group to join.
* @param {string} username - the username to join as.
* @param {string} password - the password.
* @param {Object<string,any>} [status] - the initial status of the user.
*/
ServerConnection.prototype.join = function(group, username, password) {
this.send({
ServerConnection.prototype.join = function(group, username, password, status) {
let m = {
type: 'join',
kind: 'join',
group: group,
username: username,
password: password,
});
};
if(status)
m.status = status;
this.send(m);
};
/**