lcw
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
// let url = "ws://89.40.9.89:2109/mosty-api/mosty-websocket/socket/"; //线上
|
||||
let url = "ws://155.240.22.30:2109/mosty-api/mosty-websocket/socket/"; //线上
|
||||
let url = "ws://89.40.9.93:50039/mosty-websocket/socket/"; //线上
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
url = "ws://47.108.232.77:9537/mosty-api/mosty-websocket/socket/"; //本地
|
||||
@ -86,8 +86,6 @@ class WebSoketClass {
|
||||
if (fun) fun(true);
|
||||
};
|
||||
this.ws.onclose = (e) => {
|
||||
console.log(e);
|
||||
|
||||
console.log('WebSocket连接已关闭,关闭码:', e.code, '原因:', e.reason);
|
||||
// 如果是正常关闭(1000)或手动关闭(1001),不进行重连
|
||||
if (e.code !== 1000 && e.code !== 1001) {
|
||||
@ -165,7 +163,6 @@ class WebSoketClass {
|
||||
// 接收发送消息
|
||||
getMessage() {
|
||||
this.ws.onmessage = (e) => {
|
||||
console.log(e);
|
||||
|
||||
try {
|
||||
if (e.data) {
|
||||
@ -175,6 +172,9 @@ class WebSoketClass {
|
||||
// 触发音频播放
|
||||
console.log('触发音频播放');
|
||||
emitter.emit('openYp', newsDate.data); // 传递消息数据
|
||||
} else {
|
||||
|
||||
emitter.emit('webSocketMessage', { data: newsDate.data, type: newsDate.type });
|
||||
}
|
||||
// else if (newsDate.type === 'ALARM_STOP' || newsDate.type === 'warning_stop') {
|
||||
// // 触发音频停止
|
||||
@ -187,7 +187,7 @@ class WebSoketClass {
|
||||
// emitter.emit('statusUpdate', newsDate.data);
|
||||
// }
|
||||
// // 通用消息事件
|
||||
// emitter.emit('webSocketMessage', newsDate);
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理WebSocket消息失败:', error);
|
||||
|
||||
Reference in New Issue
Block a user