diff --git a/rtpconn/webclient.go b/rtpconn/webclient.go index fc36d0a..5562a8e 100644 --- a/rtpconn/webclient.go +++ b/rtpconn/webclient.go @@ -539,7 +539,7 @@ func gotAnswer(c *webClient, id string, sdp string) error { } err := down.pc.SetRemoteDescription(webrtc.SessionDescription{ Type: webrtc.SDPTypeAnswer, - SDP: sdp, + SDP: sdp, }) if err != nil { return err @@ -1235,7 +1235,11 @@ func handleClientMessage(c *webClient, m clientMessage) error { switch m.Kind { case "clearchat": g.ClearChatHistory() - m := clientMessage{Type: "clearchat"} + m := clientMessage{ + Type: "usermessage", + Kind: "clearchat", + Privileged: true, + } clients := g.GetClients(nil) for _, cc := range clients { cc, ok := cc.(*webClient) diff --git a/static/galene.js b/static/galene.js index c5a761d..45efe50 100644 --- a/static/galene.js +++ b/static/galene.js @@ -1555,7 +1555,6 @@ function gotUserMessage(id, dest, username, time, privileged, kind, message) { console.error(`Got unprivileged message of kind ${kind}`); break; case 'mute': - console.log(id, dest, username); if(privileged) { setLocalMute(true, true); let by = username ? ' by ' + username : ''; @@ -1564,6 +1563,12 @@ function gotUserMessage(id, dest, username, time, privileged, kind, message) { console.error(`Got unprivileged message of kind ${kind}`); } break; + case 'clearchat': + if(privileged) { + clearChat(); + } else { + console.error(`Got unprivileged message of kind ${kind}`); + } default: console.warn(`Got unknown user message ${kind}`); break; @@ -2319,7 +2324,6 @@ async function serverConnect() { serverConnection.onuser = gotUser; serverConnection.onjoined = gotJoined; serverConnection.onchat = addToChatbox; - serverConnection.onclearchat = clearChat; serverConnection.onusermessage = gotUserMessage; let url = `ws${location.protocol === 'https:' ? 's' : ''}://${location.host}/ws`; diff --git a/static/protocol.js b/static/protocol.js index ae44e4b..62f524b 100644 --- a/static/protocol.js +++ b/static/protocol.js @@ -161,13 +161,6 @@ function ServerConnection() { * @type {(this: ServerConnection, id: string, dest: string, username: string, time: number, privileged: boolean, kind: string, message: unknown) => void} */ this.onusermessage = null; - /** - * onclearchat is called whenever the server requests that the chat - * be cleared. - * - * @type{(this: ServerConnection) => void} - */ - this.onclearchat = null; } /** @@ -315,10 +308,6 @@ ServerConnection.prototype.connect = async function(url) { m.privileged, m.kind, m.value, ); break; - case 'clearchat': - if(sc.onclearchat) - sc.onclearchat.call(sc); - break; case 'ping': sc.send({ type: 'pong',