Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initList() {
let realtime = new Realtime({ appId: lcGlobal.leancloud.appId, region: 'cn' });
realtime.createIMClient(this.currentClientId).then(imClient => {
//this.avIMClient = imClient;
SharedService.client = imClient;
SharedService.client.on('message', (message: Message, conversation: Conversation) => {
let eventName: string = 'lc:received:' + conversation.id;
// 检查是否开启了本地缓存聊天记录的选择,如果开启则记录在本地
if (lcGlobal.realtime_config.localCache) {
this.cacheProvider.getProvider(this.currentClientId).push(message, conversation);
}
console.log('Message received: ', message.id, message.type, JSON.stringify(message), eventName);
this.updateLastMessage(message);
this.events.publish(eventName, message);
});
return SharedService.client.getQuery().withLastMessagesRefreshed(true).find();
}).then(cons => {
.factory('LeanRT', () => {
const LeanRT = {};
const realtime = new Realtime({
appId,
appKey,
// server: 'rtm51',
plugins: [TypedMessagesPlugin, GroupchatReceiptsPlugin, TypingIndicatorPlugin],
region: 'cn' // 美国节点为 "us"
});
realtime.register([StickerMessage]);
LeanRT.realtime = realtime;
LeanRT.imClient = null;
LeanRT.currentConversation = null;
return LeanRT;
})
.service('userService', userService)