How to use the leancloud-realtime.Realtime function in leancloud-realtime

To help you get started, we’ve selected a few leancloud-realtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wujun4code / DoChat / chatkit-client / src / components / lc-conversation-list / lc-conversation-list.ts View on Github external
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 => {
github leancloud / leanmessage-demo / src / index.js View on Github external
.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)