Readd the nick to the payloads of offer/answer

The RTCSessionDescription removes custom payload attributes in it's toJSON
method. The one value we set is the nick, so we need to toJSON and toObject
the description and add the nick to the payload again.
{@see https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription/toJSON}

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-03-29 10:04:10 +01:00
Родитель 030dce73d9
Коммит c02c8c089e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -573,9 +573,18 @@
} else if(data.type === 'offer') {
console.log("OFFER", data);
}
// The RTCSessionDescription removes custom payload attributes in it's toJSON
// method. The one value we set is the nick, so we need to toJSON and toObject
// the description and add the nick to the payload again.
// {@see https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription/toJSON}
var tempString = JSON.stringify(data);
var tempData = JSON.parse(tempString);
tempData.payload.nick = data.payload.nick;
this.spreedArrayConnection.push({
ev: "message",
fn: JSON.stringify(data),
fn: JSON.stringify(tempData),
sessionId: this.sessionId
});
};