这次测试,是直接在JS端创建了一个群聊,和一个聊天室(暂态群聊),发现聊天室对象,调用join()方法和quit()方法,都会报错,说是is not a function
测试代码如下
<template>
<div id="app">
<img src="./assets/logo.png">
<router-view/>
<button @click="createConversation">创建群聊</button>
<button @click="createChatRoom">创建聊天室</button>
<button @click="test">测试退出leanCloud群聊</button>
<button @click="test2">测试退出leanCloud聊天室</button>
<button @click="test3">测试加入leanCloud群聊</button>
<button @click="test4">测试加入leanCloud聊天室</button>
</div>
</template>
<script>
/* eslint-disable spaced-comment,key-spacing,semi,indent,new-cap */
export default {
name: 'App',
data () {
return {
client: {},
conversation: {},
chatRoom:{},
conversationId:'', //非暂态对话ObjectId
chatRoomId:'' //暂态对话ObjectId
};
},
created () {
let _this = this;
_this.$realTime.createIMClient('Harry').then(function (user) {
//获取用户对象
_this.client = user;
//获取非暂态对话对象
// user.getConversation(_this.conversationId).then(function (conversation) {
// _this.conversation = conversation;
// });
//获取暂态对话对象
// user.getConversation(_this.chatRoomId).then(function (chatRoom) {
// _this.chatRoom = chatRoom;
// })
});
},
methods: {
createConversation: function () {
//创建非暂态对话对象
let _this = this;
this.client.createConversation({
members: ['Harry', 'Tom', 'Jack'],
name: '测试群聊1',
transient: false,
unique: true
}).then(function (conversation) {
console.log('创建群聊成功,conversation is:', conversation);
_this.conversation = conversation;
_this.conversationId = conversation.id;
});
},
createChatRoom: function () {
//创建暂态对话对象
let _this = this;
this.client.createConversation({
name: '测试群聊天室1',
transient: true
}).then(function (chatRoom) {
console.log('创建聊天室成功,chatRoom is:', chatRoom);
_this.chatRoom = chatRoom;
_this.chatRoom = chatRoom.id;
});
},
test: function () {
//测试退出群聊
console.log('client is:', this.client);
console.log('conversation is:', this.conversation);
this.conversation.quit().then(function (conversation) {
console.log('退出群聊成功', conversation.members);
}).catch(console.error.bind(console));
},
test2: function () {
//测试退出聊天室
console.log('client is:', this.client);
console.log('chatRoom is:', this.conversation);
this.chatRoom.quit().then(function (chatRoom) {
console.log('退出聊天室成功', chatRoom.members);
}).catch(console.error.bind(console));
},
test3: function () {
//测试加入群聊
this.conversation.join().then(function (conversation) {
console.log('加入成功', conversation.members);
}).catch(console.error.bind(console));
},
test4: function () {
//测试加入聊天室
this.chatRoom.join().then(function (chatRoom) {
console.log('加入聊天室成功', chatRoom.members);
}).catch(console.error.bind(console));
}
}
}
</script>
并且还发现,直接用js sdk里的,createChatRoom的那个方法,也会报错is not a function