diff --git a/README.PROTOCOL b/README.PROTOCOL index 3642d3e..327f0e4 100644 --- a/README.PROTOCOL +++ b/README.PROTOCOL @@ -107,7 +107,8 @@ The `join` message requests that the sender join or leave a group: kind: 'join' or 'leave', group: group, username: username, - password: password + password: password, + status: status } ``` diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index a0a5792..461b472 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -1316,9 +1316,20 @@ func handleClientMessage(c *webClient, m clientMessage) error { } if c.group != nil { - return group.ProtocolError("cannot join multiple groups") + return group.ProtocolError( + "cannot join multiple groups", + ) } c.username = m.Username + if m.Status != nil { + s, ok := m.Status.(map[string]interface{}) + if !ok { + return group.ProtocolError( + "bad type for status", + ) + } + c.status = s + } g, err := group.AddClient(m.Group, c, group.ClientCredentials{ Username: m.Username, diff --git a/static/protocol.js b/static/protocol.js index 7550801..766be50 100644 --- a/static/protocol.js +++ b/static/protocol.js @@ -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} [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); }; /**