Browse Source

Merge branch 'master' of http://121.36.37.70:3000/shaojiahao/Jinan_project

非煤矿山灾害智能感知和预警系统
邵佳豪 2 years ago
parent
commit
5a74fdc367
  1. 25
      src/app/home/commonComponents/chat-window/chat-window.component.ts
  2. 5
      src/signalRChat.ts

25
src/app/home/commonComponents/chat-window/chat-window.component.ts

@ -40,7 +40,7 @@ export class ChatWindowComponent implements OnInit {
await signalR.initSR(this.taskId);
await this.getAllMessages();
// 接收来自中心的消息
(signalR.SR as any).on('receiveMessage', (message: any) => {
console.log('收到消息', message)
@ -50,7 +50,28 @@ export class ChatWindowComponent implements OnInit {
this.scrollToBottom()
}, 0);
}
})
});
// 接收群组信息
(signalR.SR as any).on('receiveGroup', (group: any) => {
try {
console.log('收到群组信息', group)
this.isLoading = true
this.MessagesList = group.taskChatMessages || [];
this.members = group.members || [];
this.members.forEach(item => {
this.chatName += (item.name || '') + ' '
});
setTimeout(() => {
this.scrollToBottom()
}, 0);
this.isLoading = false
console.log('chatName', this.chatName)
console.log('消息列表', this.MessagesList)
} catch (error) {
console.log(error, 'error')
}
});
}
/**
*

5
src/signalRChat.ts

@ -26,7 +26,10 @@ export default {
try {
await that.SR.start();
console.assert(that.SR.state === signalR.HubConnectionState.Connected)
await that.SR.send("joinRoom", id).then(() => console.log("已加入聊天室"));
// await that.SR.send("joinRoom", id).then(() => console.log("已加入聊天室"));
await that.SR.send("joinRoom", id);
console.log("已加入聊天室")
} catch (err) {
setTimeout(start, 5000);
}

Loading…
Cancel
Save