-
Notifications
You must be signed in to change notification settings - Fork 19
/
ot-publisher.vue
48 lines (44 loc) · 938 Bytes
/
ot-publisher.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<template>
<div></div>
</template>
<script>
import OT from '@opentok/client'
export default {
name: 'ot-publisher',
props: {
session: {
type: OT.Session,
required: false
},
opts: {
type: Object,
required: false
}
},
mounted: function() {
const publisher = OT.initPublisher(this.$el, this.opts, (err) => {
if (err) {
this.$emit('error', err);
} else {
this.$emit('publisherCompleted');
}
});
this.$emit('publisherCreated', publisher);
const publish = () => {
this.session.publish(publisher, (err) => {
if (err) {
this.$emit('error', err);
} else {
this.$emit('publisherConnected', publisher);
}
});
};
if (this.session && this.session.isConnected()) {
publish()
}
if (this.session) {
this.session.on('sessionConnected', publish)
}
}
}
</script>