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
49
50
51
52
53
54
55
56
57
58
| <template>
| <view>
|
| </view>
| </template>
|
| <script>
| export default {
| data() {
| return {
| ws: null,
| }
| },
| onShow() {
| this.init()
| },
| methods: {
| init() {
| this.ws = new WebSocket("ws://127.0.0.1:9090/pswcs/console/websocket")
| this.ws.onopen = this.webSocketOnOpen
| this.ws.onerror = this.webSocketOnError
| this.ws.onmessage = this.webSocketOnMessage
| this.ws.onclose = this.webSocketClose
| // console.log(this.ws)
|
| },
| webSocketOnOpen(e) {
| console.log("open");
|
| this.sendWs(JSON.stringify({
| url: 'getTvConfig',
| data: '1'
| }))
| },
| webSocketOnError(e) {
| console.log(e);
| },
| webSocketOnMessage(e) {
| const result = JSON.parse(e.data);
| if (result.url == "getTvConfig") {
| console.log(result.result)
| }
| },
| webSocketClose(e) {
| console.log("close");
| },
| sendWs(message) {
| if (this.ws.readyState == WebSocket.OPEN) {
| this.ws.send(message)
| }
| }
| }
| }
| </script>
|
| <style>
|
| </style>
|
|