websocket调整&ibp设备配置调整
This commit is contained in:
parent
88253207d8
commit
0c08e93ba1
@ -32,7 +32,6 @@
|
|||||||
"recordrtc": "^5.5.9",
|
"recordrtc": "^5.5.9",
|
||||||
"script-loader": "^0.7.2",
|
"script-loader": "^0.7.2",
|
||||||
"sessionstorage": "^0.1.0",
|
"sessionstorage": "^0.1.0",
|
||||||
"sockjs-client": "^1.4.0",
|
|
||||||
"stompjs": "^2.3.3",
|
"stompjs": "^2.3.3",
|
||||||
"storejs": "^1.0.25",
|
"storejs": "^1.0.25",
|
||||||
"three": "^0.107.0",
|
"three": "^0.107.0",
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
import SockJS from 'sockjs-client';
|
|
||||||
import Stomp from 'stompjs';
|
import Stomp from 'stompjs';
|
||||||
import { getBaseUrl } from '@/utils/baseUrl';
|
import { getBaseUrl } from '@/utils/baseUrl';
|
||||||
|
|
||||||
const BASE_API = getBaseUrl();
|
const BASE_API = getBaseUrl();
|
||||||
let baseUrl = "http://192.168.3.6:9600";//本地旭强
|
let baseUrl = 'http://192.168.3.6:9600';// 本地旭强
|
||||||
if(BASE_API == 'https://joylink.club/jlcloud'){
|
if (BASE_API == 'https://joylink.club/jlcloud') {
|
||||||
baseUrl = "https://joylink.club/relay";
|
baseUrl = 'https://joylink.club/relay';
|
||||||
}else if(BASE_API == 'https://test.joylink.club/jlcloud'){
|
} else if (BASE_API == 'https://test.joylink.club/jlcloud') {
|
||||||
baseUrl = "https://test.joylink.club/relay";
|
baseUrl = 'https://test.joylink.club/relay';
|
||||||
}
|
}
|
||||||
|
|
||||||
class StompClient {
|
class StompClient {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const ws = new SockJS(`${baseUrl}/ws-relay`);
|
const ws = new WebSocket(`${baseUrl}/ws-relay`.replace(/https/, 'wss').replace(/http/, 'ws'));
|
||||||
this.client = Stomp.over(ws);
|
this.client = Stomp.over(ws);
|
||||||
this.client.debug = function (message) {
|
this.client.debug = function (message) {
|
||||||
console.debug(message);
|
console.debug(message);
|
||||||
@ -24,27 +22,27 @@ class StompClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.onUsed = true;
|
this.onUsed = true;
|
||||||
const that = this;
|
const that = this;
|
||||||
const header = {
|
const header = {
|
||||||
login: 'relay',
|
login: 'relay',
|
||||||
passcode: 'relay'
|
passcode: 'relay'
|
||||||
};
|
};
|
||||||
this.client.connect(header,
|
this.client.connect(header,
|
||||||
()=>{
|
()=>{
|
||||||
that.connected = true;
|
that.connected = true;
|
||||||
// 重连时需要重新订阅
|
// 重连时需要重新订阅
|
||||||
that.subscribeMap.forEach((subscribe, dest) => {
|
that.subscribeMap.forEach((subscribe, dest) => {
|
||||||
that.subscribe(subscribe.dest, subscribe.handler);
|
that.subscribe(subscribe.dest, subscribe.handler);
|
||||||
});
|
});
|
||||||
resolve();
|
resolve();
|
||||||
},
|
},
|
||||||
(error)=>{
|
(error)=>{
|
||||||
console.error(error);
|
console.error(error);
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@ export function getBaseUrl() {
|
|||||||
let BASE_API;
|
let BASE_API;
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
// BASE_API = 'https://joylink.club/jlcloud';
|
// BASE_API = 'https://joylink.club/jlcloud';
|
||||||
BASE_API = 'https://test.joylink.club/jlcloud';
|
// BASE_API = 'https://test.joylink.club/jlcloud';
|
||||||
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪
|
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪
|
||||||
// BASE_API = 'http://192.168.3.6:9000'; // 旭强
|
BASE_API = 'http://192.168.3.6:9000'; // 旭强
|
||||||
// BASE_API = 'http://192.168.3.41:9000'; // 张赛
|
// BASE_API = 'http://192.168.3.41:9000'; // 张赛
|
||||||
// BASE_API = 'http://192.168.3.82:9000'; // 杜康
|
// BASE_API = 'http://192.168.3.82:9000'; // 杜康
|
||||||
// BASE_API = 'http://b29z135112.zicp.vip';
|
// BASE_API = 'http://b29z135112.zicp.vip';
|
||||||
|
@ -3,7 +3,6 @@ import { checkLoginLine } from '@/api/login';
|
|||||||
import { getBaseUrl } from '@/utils/baseUrl';
|
import { getBaseUrl } from '@/utils/baseUrl';
|
||||||
import { MessageBox } from 'element-ui';
|
import { MessageBox } from 'element-ui';
|
||||||
import store from '@/store/index_APP_TARGET';
|
import store from '@/store/index_APP_TARGET';
|
||||||
import SockJS from 'sockjs-client';
|
|
||||||
import Stomp from 'stompjs';
|
import Stomp from 'stompjs';
|
||||||
|
|
||||||
const isDev = process.env.NODE_ENV === 'development';
|
const isDev = process.env.NODE_ENV === 'development';
|
||||||
@ -19,7 +18,7 @@ var StompClient = function (headers) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
StompClient.prototype = {
|
StompClient.prototype = {
|
||||||
socket: null,
|
websocket: null,
|
||||||
clientIns: null,
|
clientIns: null,
|
||||||
url: '',
|
url: '',
|
||||||
status: false,
|
status: false,
|
||||||
@ -34,27 +33,10 @@ StompClient.prototype = {
|
|||||||
|
|
||||||
// 连接服务端
|
// 连接服务端
|
||||||
connect() {
|
connect() {
|
||||||
// 建立连接对象(还未发起连接)
|
|
||||||
// (null, {transports:['websocket']})虽可以解决连接关闭后xhr_streaming无限循环
|
|
||||||
// 但是该参数只会允许websockets,若不支持,直接报错
|
|
||||||
// 注意sockjs会做降级处理,优先处理websockets,若浏览器不支持websockets
|
|
||||||
// 则会降级为xhr_streaming(轮询),继续不支持的时候会降级为xhr-polling
|
|
||||||
|
|
||||||
// const oldtransportClose = SockJS.prototype._transportClose;
|
|
||||||
// SockJS.prototype._transportClose = function(code, reason) {
|
|
||||||
// // To do
|
|
||||||
// // ...
|
|
||||||
// console.log(reason + '-----------------', this._transport);
|
|
||||||
// if (this._transport && this._transport.close) {
|
|
||||||
// this._transport.close();
|
|
||||||
// }
|
|
||||||
// return oldtransportClose.call(this, code, reason);
|
|
||||||
// };
|
|
||||||
|
|
||||||
// 向服务器发起websocket连接并发送CONNECT帧
|
// 向服务器发起websocket连接并发送CONNECT帧
|
||||||
this.socket = new SockJS(websocketUrl + getToken());
|
this.websocket = new WebSocket(this.url.replace(/https/, 'wss').replace(/http/, 'ws'));
|
||||||
// 获取 STOMP 子协议的客户端对象
|
// 获取 STOMP 子协议的客户端对象
|
||||||
this.clientIns = Stomp.over(this.socket);
|
this.clientIns = Stomp.over(this.websocket);
|
||||||
this.closeStompDebug();
|
this.closeStompDebug();
|
||||||
const that = this;
|
const that = this;
|
||||||
this.clientIns.connect({ 'X-Token': getToken() }, () => {
|
this.clientIns.connect({ 'X-Token': getToken() }, () => {
|
||||||
@ -70,7 +52,6 @@ StompClient.prototype = {
|
|||||||
});
|
});
|
||||||
// sock断开回调
|
// sock断开回调
|
||||||
that.clientIns.ws.onclose = () => {
|
that.clientIns.ws.onclose = () => {
|
||||||
// Message.error(`通信连接已断开!`);
|
|
||||||
console.info(`通信连接已断开!`);
|
console.info(`通信连接已断开!`);
|
||||||
checkLoginLine().then(() => {
|
checkLoginLine().then(() => {
|
||||||
that.count++;
|
that.count++;
|
||||||
@ -161,8 +142,8 @@ StompClient.prototype = {
|
|||||||
this.clientIns.disconnect();
|
this.clientIns.disconnect();
|
||||||
}
|
}
|
||||||
this.isPassived = false;
|
this.isPassived = false;
|
||||||
this.socket.close();
|
this.websocket.close();
|
||||||
this.socket = null;
|
this.websocket = null;
|
||||||
this.clientIns = null;
|
this.clientIns = null;
|
||||||
}
|
}
|
||||||
this.status = false;
|
this.status = false;
|
||||||
|
@ -279,7 +279,6 @@ import { getDeviceDetail, setIbpConfig} from '@/api/project';
|
|||||||
import { deepAssign } from '@/utils/index';
|
import { deepAssign } from '@/utils/index';
|
||||||
import { getAllMapOnline, getStationListNeedAttendant } from '@/api/jmap/map';
|
import { getAllMapOnline, getStationListNeedAttendant } from '@/api/jmap/map';
|
||||||
const propMap = {
|
const propMap = {
|
||||||
addr: '网关位地址',
|
|
||||||
ribpsd: 'IBP盘试灯按钮',
|
ribpsd: 'IBP盘试灯按钮',
|
||||||
wibpsdand: 'IBP盘试灯指示灯',
|
wibpsdand: 'IBP盘试灯指示灯',
|
||||||
afczjConfig: {
|
afczjConfig: {
|
||||||
@ -446,7 +445,7 @@ const propMap = {
|
|||||||
rxxsd: '下行试灯按钮[信号配置]',
|
rxxsd: '下行试灯按钮[信号配置]',
|
||||||
wfmq: '蜂鸣器[信号配置]',
|
wfmq: '蜂鸣器[信号配置]',
|
||||||
wsxjjtccand: '上行紧急停车按钮灯[信号配置]',
|
wsxjjtccand: '上行紧急停车按钮灯[信号配置]',
|
||||||
wsxjjtczsd: '上行取消紧急停车指示灯[信号配置]',
|
wsxjjtczsd: '上行紧急停车指示灯[信号配置]',
|
||||||
wsxjljcand: '上行警铃解除按钮灯[信号配置]',
|
wsxjljcand: '上行警铃解除按钮灯[信号配置]',
|
||||||
wsxkcand: '上行扣车按钮灯[信号配置]',
|
wsxkcand: '上行扣车按钮灯[信号配置]',
|
||||||
wsxkczsd: '上行扣车指示灯[信号配置]',
|
wsxkczsd: '上行扣车指示灯[信号配置]',
|
||||||
@ -455,7 +454,7 @@ const propMap = {
|
|||||||
wsxqxkczsd: '上行取消扣车指示灯[信号配置]',
|
wsxqxkczsd: '上行取消扣车指示灯[信号配置]',
|
||||||
wsxsdand: '上行试灯按钮灯[信号配置]',
|
wsxsdand: '上行试灯按钮灯[信号配置]',
|
||||||
wxxjjtccand: '下行紧急停车按钮灯[信号配置]',
|
wxxjjtccand: '下行紧急停车按钮灯[信号配置]',
|
||||||
wxxjjtczsd: '下行取消紧急停车按钮灯[信号配置]',
|
wxxjjtczsd: '下行紧急停车指示灯[信号配置]',
|
||||||
wxxjljcand: '下行警铃解除按钮灯[信号配置]',
|
wxxjljcand: '下行警铃解除按钮灯[信号配置]',
|
||||||
wxxkcand: '下行扣车按钮灯[信号配置]',
|
wxxkcand: '下行扣车按钮灯[信号配置]',
|
||||||
wxxkczsd: '下行扣车指示灯[信号配置]',
|
wxxkczsd: '下行扣车指示灯[信号配置]',
|
||||||
@ -711,7 +710,7 @@ export default {
|
|||||||
items:[
|
items:[
|
||||||
{ prop:'wfmq', label: '蜂鸣器:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wfmq', label: '蜂鸣器:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wsxjjtccand', label: '上行紧急停车按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wsxjjtccand', label: '上行紧急停车按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wsxjjtczsd', label: '上行取消紧急停车指示灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wsxjjtczsd', label: '上行紧急停车指示灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wsxjljcand', label: '上行警铃解除按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wsxjljcand', label: '上行警铃解除按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wsxkcand', label: '上行扣车按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wsxkcand', label: '上行扣车按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wsxkczsd', label: '上行扣车指示灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wsxkczsd', label: '上行扣车指示灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
@ -720,7 +719,7 @@ export default {
|
|||||||
{ prop:'wsxqxkczsd', label: '上行取消扣车指示灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wsxqxkczsd', label: '上行取消扣车指示灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wsxsdand', label: '上行试灯按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wsxsdand', label: '上行试灯按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wxxjjtccand', label: '下行紧急停车按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wxxjjtccand', label: '下行紧急停车按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wxxjjtczsd', label: '下行取消紧急停车按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wxxjjtczsd', label: '下行紧急停车指示灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wxxjljcand', label: '下行警铃解除按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wxxjljcand', label: '下行警铃解除按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wxxkcand', label: '下行扣车按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wxxkcand', label: '下行扣车按钮灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
{ prop:'wxxkczsd', label: '下行扣车指示灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
{ prop:'wxxkczsd', label: '下行扣车指示灯:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, size: 'small', noControls: true},
|
||||||
|
Loading…
Reference in New Issue
Block a user