AC: * align config approach with AUI application * apply the standard way of injecting configuration through boot files. * removed some files which are already part of RTC CDK and not used in CSC anymore Note: you have to move your personal "src/config.js" to "src/config/app.js" manually in your working folder. Change-Id: If5a615f0691631e4410e6780a025fed54133147bmr10.1.1
parent
24b2843f34
commit
bd6a332eab
@ -1,48 +0,0 @@
|
|||||||
|
|
||||||
import config from '../config'
|
|
||||||
import Vue from 'vue'
|
|
||||||
import { getJsonBody } from './utils'
|
|
||||||
|
|
||||||
export function create () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
Vue.http.post('api/rtcsessions/').then((res) => {
|
|
||||||
resolve(res)
|
|
||||||
}).catch((err) => {
|
|
||||||
reject(err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getByUrl (url) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
Vue.http.get(url).then((res) => {
|
|
||||||
resolve(getJsonBody(res.body))
|
|
||||||
}).catch((err) => {
|
|
||||||
reject(err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createSession () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
Promise.resolve().then(() => {
|
|
||||||
return create()
|
|
||||||
}).then((res) => {
|
|
||||||
return getByUrl(config.baseHttpUrl + res.headers.get('Location'))
|
|
||||||
}).then((res) => {
|
|
||||||
resolve(res)
|
|
||||||
}).catch((err) => {
|
|
||||||
reject(err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createSessionToken () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
createSession().then((res) => {
|
|
||||||
resolve(res.rtc_browser_token)
|
|
||||||
}).catch((err) => {
|
|
||||||
reject(err)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
@ -0,0 +1,6 @@
|
|||||||
|
import appConfig from '../config/app'
|
||||||
|
|
||||||
|
export default async ({ Vue, store, router, app }) => {
|
||||||
|
Vue.prototype.$appConfig = appConfig
|
||||||
|
app.$appConfig = appConfig
|
||||||
|
}
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
import Vue from 'vue'
|
|
||||||
import config from 'src/config'
|
|
||||||
|
|
||||||
Vue.use({
|
|
||||||
install (Vue, options) {
|
|
||||||
Vue.$config = config
|
|
||||||
Vue.prototype.$config = config
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default ({ app }) => {
|
|
||||||
app.config = config
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
|
|
||||||
const cdk = {}
|
|
||||||
import config from '../config'
|
|
||||||
import loadScript from 'load-script'
|
|
||||||
|
|
||||||
const scriptId = 'cdk'
|
|
||||||
const scriptUrl = config.baseHttpUrl + '/rtc/files/dist/cdk-prod.js'
|
|
||||||
const webSocketUrl = config.baseWsUrl + '/rtc/api'
|
|
||||||
|
|
||||||
export function loadCdkLib () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
if (!document.getElementById(scriptId)) {
|
|
||||||
loadScript(scriptUrl, {
|
|
||||||
attrs: {
|
|
||||||
id: scriptId
|
|
||||||
}
|
|
||||||
}, function (err, script) {
|
|
||||||
if (err) {
|
|
||||||
reject(err)
|
|
||||||
} else {
|
|
||||||
resolve(script)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
resolve()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function connectCdkClient (session) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const client = new cdk.Client({
|
|
||||||
url: webSocketUrl,
|
|
||||||
userSession: session
|
|
||||||
})
|
|
||||||
client.onConnect(() => {
|
|
||||||
resolve(client)
|
|
||||||
})
|
|
||||||
client.onDisconnect(() => {
|
|
||||||
reject(new Error(client.disconnectReason))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function connectCdkNetworkByClient (client, session, networkTag) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const network = client.getNetworkByTag(networkTag)
|
|
||||||
network.onConnect(() => {
|
|
||||||
resolve(network)
|
|
||||||
})
|
|
||||||
network.onDisconnect(() => {
|
|
||||||
reject(new Error(network.disconnectReason))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function connectCdkNetwork (session, networkTag) {
|
|
||||||
const client = await connectCdkClient(session)
|
|
||||||
return connectCdkNetworkByClient(client, session, networkTag)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function connectDefaultCdkNetwork (session) {
|
|
||||||
return connectCdkNetwork(session, 'sip')
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getChromeExtensionUrl () {
|
|
||||||
return cdk.getChromeExtensionURL()
|
|
||||||
}
|
|
Loading…
Reference in new issue