openvidu-browser and openvidu-server version check

This commit is contained in:
pabloFuente 2019-04-22 18:22:49 +02:00
parent 43e5f3e741
commit e07583f0b9
5 changed files with 584 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,8 @@ import RpcBuilder = require('../OpenViduInternal/KurentoUtils/kurento-jsonrpc');
import platform = require('platform');
platform['isIonicIos'] = (platform.product === 'iPhone' || platform.product === 'iPad') && platform.ua!!.indexOf('Safari') === -1;
const packageJson = require('../../package.json');
/**
* Entrypoint of OpenVidu Browser library.
* Use it to initialize objects of type [[Session]], [[Publisher]] and [[LocalRecorder]]
@ -81,9 +83,16 @@ export class OpenVidu {
* @hidden
*/
webrtcStatsInterval: number = 0;
/**
* @hidden
*/
libraryVersion: string;
constructor() {
this.libraryVersion = packageJson.version;
console.info("'OpenVidu' initialized");
console.info("openvidu-browser version: " + this.libraryVersion);
if (platform.os!!.family === 'iOS' || platform.os!!.family === 'Android') {
// Listen to orientationchange only on mobile devices

View File

@ -1145,6 +1145,7 @@ export class Session implements EventDispatcher {
const turnCredential = url.searchParams.get('turnCredential');
const role = url.searchParams.get('role');
const webrtcStatsInterval = url.searchParams.get('webrtcStatsInterval');
const openviduServerVersion = url.searchParams.get('version');
if (!!secret) {
this.openvidu.secret = secret;
@ -1168,6 +1169,14 @@ export class Session implements EventDispatcher {
if (!!webrtcStatsInterval) {
this.openvidu.webrtcStatsInterval = +webrtcStatsInterval;
}
if (!!openviduServerVersion) {
console.info("openvidu-server version: " + openviduServerVersion);
if (openviduServerVersion !== this.openvidu.libraryVersion) {
console.error('OpenVidu Server (' + openviduServerVersion +
') and OpenVidu Browser (' + this.openvidu.libraryVersion +
') versions do NOT match. There may be incompatibilities')
}
}
this.openvidu.wsUri = 'wss://' + url.host + '/openvidu';
this.openvidu.httpUri = 'https://' + url.host;

View File

@ -222,7 +222,11 @@ public class OpenviduConfig {
}
public String getOpenViduServerVersion() {
return this.buildProperties.get("version.openvidu.server");
String v = this.buildProperties.get("version.openvidu.server");
if (v == null) {
v = this.getVersion();
}
return v;
}
public String getVersion() {

View File

@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import io.openvidu.java.client.OpenViduRole;
import io.openvidu.server.OpenViduServer;
import io.openvidu.server.config.OpenviduConfig;
import io.openvidu.server.coturn.CoturnCredentialsService;
import io.openvidu.server.coturn.TurnCredentials;
import io.openvidu.server.kurento.core.KurentoTokenOptions;
@ -31,6 +32,9 @@ public class TokenGeneratorDefault implements TokenGenerator {
@Autowired
private CoturnCredentialsService coturnCredentialsService;
@Autowired
protected OpenviduConfig openviduConfig;
@Override
public Token generateToken(String sessionId, OpenViduRole role, String serverMetadata,
KurentoTokenOptions kurentoTokenOptions) {
@ -38,6 +42,7 @@ public class TokenGeneratorDefault implements TokenGenerator {
token += "?sessionId=" + sessionId;
token += "&token=" + RandomStringGenerator.generateRandomChain();
token += "&role=" + role.name();
token += "&version=" + openviduConfig.getOpenViduServerVersion();
TurnCredentials turnCredentials = null;
if (this.coturnCredentialsService.isCoturnAvailable()) {
turnCredentials = coturnCredentialsService.createUser();