|
|
@@ -290,9 +290,33 @@ export default {
|
|
|
// ****************************************************************************************************************
|
|
|
// WebSocket相关
|
|
|
// ****************************************************************************************************************
|
|
|
+ getUrl() {
|
|
|
+ const protocol = location.protocol
|
|
|
+ const hostname = location.hostname
|
|
|
+ const port = location.port
|
|
|
+ let prefix
|
|
|
+ if (protocol === 'https:') {
|
|
|
+ if (port === '' || port === 443) {
|
|
|
+ prefix = 'wss://' + hostname
|
|
|
+ } else {
|
|
|
+ prefix = 'wss://' + hostname + ':' + port
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (port === '' || port === 80) {
|
|
|
+ prefix = 'ws://' + hostname
|
|
|
+ } else {
|
|
|
+ prefix = 'ws://' + hostname + ':' + port
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var token = '0123456789'
|
|
|
+ var params = 'token=' + token
|
|
|
+ return prefix + '/bgws/frontend?' + params
|
|
|
+ },
|
|
|
initWebSocket() {
|
|
|
if ('WebSocket' in window) {
|
|
|
- const wsUrl = 'ws://localhost:4030/bgws/frontend'
|
|
|
+ const wsUrl = this.getUrl()
|
|
|
+ console.log(wsUrl)
|
|
|
this.wsClient = new WebSocket(wsUrl)
|
|
|
const that = this
|
|
|
this.wsClient.onopen = function() {
|