fix: 修复了一些东西,新增了方法
This commit is contained in:
@@ -104,10 +104,14 @@ export class WebSocketManager {
|
||||
}
|
||||
}
|
||||
|
||||
handleMessage(data) {
|
||||
// 如果对象中有clientId则给websocket发送
|
||||
if (data.clientId) {
|
||||
const userId = uni.getStorageSync('user_id'); // 实际项目中从存储获取
|
||||
getUserIdAndBindClientId() {
|
||||
const userId = uni.getStorageSync('user_id'); // 实际项目中从存储获取
|
||||
if (userId == null || userId === 'user-' || userId === '') {
|
||||
// 等待10秒后获取
|
||||
setTimeout(() => {
|
||||
this.getUserIdAndBindClientId();
|
||||
}, 10000)
|
||||
} else {
|
||||
const bindMessage = {
|
||||
request_type: 'bind',
|
||||
user_type: 'user',
|
||||
@@ -115,6 +119,28 @@ export class WebSocketManager {
|
||||
};
|
||||
this.send(bindMessage);
|
||||
}
|
||||
return userId;
|
||||
}
|
||||
|
||||
handleMessage(data) {
|
||||
// 如果对象中有clientId则给websocket发送
|
||||
if (data.clientId) {
|
||||
|
||||
this.getUserIdAndBindClientId(data.clientId);
|
||||
// const userId = uni.getStorageSync('user_id'); // 实际项目中从存储获取
|
||||
// if (userId == null) {
|
||||
// setTimeout(() => {
|
||||
// }, 10000)
|
||||
// } else {
|
||||
// const bindMessage = {
|
||||
// request_type: 'bind',
|
||||
// user_type: 'user',
|
||||
// sender_user_id: `user-${userId}`,
|
||||
// };
|
||||
// this.send(bindMessage);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// 处理聊天消息
|
||||
if (data.message_type !== undefined) {
|
||||
|
||||
Reference in New Issue
Block a user