Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 7d22e49

Browse files
committed
Restore v11Client.js.
Protocol version was upgraded to v1.2. We don't need to touch v1.1 protocol handler.
1 parent 07722ac commit 7d22e49

File tree

1 file changed

+11
-34
lines changed

1 file changed

+11
-34
lines changed

source/portal/v11Client.js

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
var log = require('./logger').logger.getLogger('V11Client');
88
var requestData = require('./requestDataValidator');
9-
const { v4: uuid } = require('uuid');
109

1110
var idPattern = /^[0-9a-zA-Z\-]+$/;
1211
function isValidIdString(str) {
@@ -79,7 +78,7 @@ var V11Client = function(clientId, sigConnection, portal) {
7978
};
8079

8180
const validateSubReq = (subReq) => {
82-
if ((!subReq.media && !subReq.data) || (subReq.media && !subReq.media.audio && !subReq.media.video)) {
81+
if (!subReq.media || !(subReq.media.audio || subReq.media.video)) {
8382
return Promise.reject('Bad subscription request');
8483
}
8584
return requestData.validate('subscription-request', subReq);
@@ -95,21 +94,17 @@ var V11Client = function(clientId, sigConnection, portal) {
9594
const validateSOAC = (SOAC) => {
9695
return validateId('session id', SOAC.id)
9796
.then(() => {
98-
if (SOAC.signaling.type === 'offer' ||
99-
SOAC.signaling.type === 'answer' ||
100-
SOAC.signaling.type === 'candidate' ||
101-
SOAC.signaling.type === 'removed-candidates') {
97+
if (SOAC.signaling.type === 'offer'
98+
|| SOAC.signaling.type === 'answer'
99+
|| SOAC.signaling.type === 'candidate'
100+
|| SOAC.signaling.type === 'removed-candidates') {
102101
return Promise.resolve(SOAC);
103102
} else {
104103
return Promise.reject('Invalid signaling type');
105104
}
106105
});
107106
};
108107

109-
const uuidWithoutDash = function() {
110-
return uuid().replace(/-/g, '');
111-
};
112-
113108
const listenAt = (socket) => {
114109
socket.on('text', function(textReq, callback) {
115110
if(!that.inRoom){
@@ -129,22 +124,13 @@ var V11Client = function(clientId, sigConnection, portal) {
129124
return safeCall(callback, 'error', 'Illegal request');
130125
}
131126

132-
var stream_id = uuidWithoutDash();
133-
let transport_id;
127+
var stream_id = Math.round(Math.random() * 1000000000000000000) + '';
134128
return validatePubReq(pubReq)
135129
.then((req) => {
136-
if (pubReq.transport && pubReq.transport.type == 'quic') {
137-
req.type = 'quic';
138-
if (!req.transport.id) {
139-
req.transport.id = uuidWithoutDash();
140-
}
141-
transport_id = req.transport.id;
142-
} else {
143-
req.type = 'webrtc'; //FIXME: For backend compatibility with v3.4 clients.
144-
}
130+
req.type = 'webrtc';//FIXME: For backend compatibility with v3.4 clients.
145131
return portal.publish(clientId, stream_id, req);
146132
}).then((result) => {
147-
safeCall(callback, 'ok', {id: stream_id, transportId: transport_id});
133+
safeCall(callback, 'ok', {id: stream_id});
148134
}).catch(onError('publish', callback));
149135
});
150136

@@ -179,22 +165,13 @@ var V11Client = function(clientId, sigConnection, portal) {
179165
return safeCall(callback, 'error', 'Illegal request');
180166
}
181167

182-
var subscription_id = uuid().replace(/-/g,'');
183-
let transport_id;
168+
var subscription_id = Math.round(Math.random() * 1000000000000000000) + '';
184169
return validateSubReq(subReq)
185170
.then((req) => {
186-
if (req.transport && req.transport.type == 'quic') {
187-
req.type = 'quic';
188-
if (!req.transport.id) {
189-
req.transport.id = uuidWithoutDash();
190-
}
191-
transport_id = req.transport.id;
192-
} else {
193-
req.type = 'webrtc';//FIXME: For backend compatibility with v3.4 clients.
194-
}
171+
req.type = 'webrtc';//FIXME: For backend compatibility with v3.4 clients.
195172
return portal.subscribe(clientId, subscription_id, req);
196173
}).then((result) => {
197-
safeCall(callback, 'ok', {id: subscription_id, transportId: transport_id});
174+
safeCall(callback, 'ok', {id: subscription_id});
198175
}).catch(onError('subscribe', callback));
199176
});
200177

0 commit comments

Comments
 (0)