Skip to content

Commit

Permalink
Merge pull request #522 from ant-media/fix/issue-369
Browse files Browse the repository at this point in the history
Extends fields for join/leave commands
  • Loading branch information
mekya authored Dec 10, 2024
2 parents dcc3e0b + 48c2dd9 commit 203e8db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/main/js/webrtc_adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,15 +550,22 @@ export class WebRTCAdaptor {
* @param {string=} mode : legacy for older implementation (default value)
* mcu for merging streams
* amcu: audio only conferences with mixed audio
* @param {string=} streamName : name of the stream
* @param {string=} role : role for the stream. It is used for selective forwarding of subtracks in conference mode.
* @param {string=} metadata : a free text information for the stream to AMS.
*/
joinRoom(roomName, streamId, mode) {
joinRoom(roomName, streamId, mode, streamName, role, metadata) {
this.roomName = roomName;

let jsCmd = {
command: "joinRoom",
room: roomName,
mainTrack: roomName,
streamId: streamId,
mode: mode,
streamName: streamName,
role: role,
metadata: metadata,
}
this.webSocketAdaptor.send(JSON.stringify(jsCmd));
}
Expand Down Expand Up @@ -758,15 +765,18 @@ export class WebRTCAdaptor {
* Called to leave from a conference room. AMS responds with leavedTheRoom message.
* Parameters:
* @param {string} roomName : unique id for the conference room
* @param {string=} streamId : unique id for the stream that is streamed by this @WebRTCAdaptor
*/
leaveFromRoom(roomName) {
leaveFromRoom(roomName, streamId) {
for (var key in this.remotePeerConnection) {
this.closePeerConnection(key);
}
this.roomName = roomName;
var jsCmd = {
command: "leaveFromRoom",
room: roomName,
mainTrack: roomName,
streamId: streamId,
};
Logger.debug("leave request is sent for " + roomName);

Expand Down
7 changes: 6 additions & 1 deletion src/test/js/webrtc_adaptor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -897,15 +897,20 @@ describe("WebRTCAdaptor", function() {
let jsCmd = {
command: "joinRoom",
room: roomId,
mainTrack: roomId,
streamId: streamId,
mode: "multitrack",
streamName: "streamName",
role: "role",
metadata: "metadata",

}

let webSocketAdaptor = sinon.mock(adaptor.webSocketAdaptor);

let sendExpectation = webSocketAdaptor.expects("send").once().withArgs(JSON.stringify(jsCmd));

adaptor.joinRoom(roomId, streamId, "multitrack");
adaptor.joinRoom(roomId, streamId, "multitrack", "streamName", "role", "metadata");

sendExpectation.verify()

Expand Down

0 comments on commit 203e8db

Please sign in to comment.