【问题标题】:Which kind of database and chat library is good for chat based application using Ionic framework [closed]哪种数据库和聊天库适合使用 Ionic 框架的基于聊天的应用程序 [关闭]
【发布时间】:2018-10-20 16:04:56
【问题描述】:

我正在尝试构建一个类似于 Whatsapp 的基于聊天的应用程序。 使用 Couch Database 和 socket.io 聊天库等数据库构建基于聊天的应用程序...

我面临的问题是:

  1. 当我尝试在一对一聊天窗口或群聊窗口中查看旧消息时,消息延迟

  2. 当我尝试从一台设备向另一台设备发送消息时(即,一个用户向另一位用户发送消息或表情符号需要大量时间)

  3. 获取旧的聊天记录非常糟糕

  4. 通过套接字发送消息不会立即触发

  5. 单击“发送按钮”后无法查看图像 - 需要花费大量时间查看图像预览以及发送后一次

vi) 创建组后,要将其显示在列表视图中,需要更多时间

我的问题是:

我应该使用哪个聊天库而不是 socket.io 来发送像 WhatsApp 聊天这样的消息

我应该使用哪个数据库而不是沙发数据库?

我研究了很多关于 Redis、Couch DB 和 Mnesia Db 以及 pusher、pubnub、chat sdk 等。

请问,谁能建议我应该使用哪个聊天应用程序(快速传递的消息,可靠、高效、消息存储和获取以及即使在离线时也能显示消息)?

【问题讨论】:

    标签: angularjs node.js socket.io couchdb chat


    【解决方案1】:

    我建议使用名为 ChatEngine 的 PubNub 固执己见的 JavaScript 框架。它消除了与 PubNub 聊天所涉及的大量繁重工作。它有表情符号、打字指示器、降价等插件。

    消息传递 SLA 全局

    以下是一些示例代码,可帮助您开始使用 JavaScript 进行 1:1 私人聊天。确保您使用ChatEngine setup button 为您的帐户准备后端。

    import ChatEngineCore from 'chat-engine';
    
    // Init ChatEngine with PubNub
    const publishKey = '__Your_PubNub_Publish_Key__';
    const subscribeKey = '__Your_PubNub_Subscribe_Key__';
    
    const ChatEngine = ChatEngineCore.create({
      publishKey,
      subscribeKey,
    }, {
      globalChannel: 'global',
    });
    
    const user = {
        uuid: 'randomstringofchars',
        name: 'John Smith'
    }
    
    const chats = {};
    
    ChatEngine.connect(user.uuid, user);
    
    ChatEngine.on('$.ready', function(data) {
    
        // store my new user as `me`
        let me = data.me;
    
        // returns a ChatEngine chat object
        function makePrivateChat(theirUserId) {
            const chatKey = [theirUserId, me.uuid].sort().join('-');
    
            // Don't make the same 1:1 chat if it already exists
            if (chats[chatKey]) {
                return;
            }
    
            // true for private chat
            const chat = new ChatEngine.Chat(chatKey, true);
    
            chats[chatKey] = chat;
        }
    
        // Auto add a 1:1 chat to UI when invited by someone
        me.direct.on('$.invite', makePrivateChat);
    
        // Define a button for making new 1:1 chats in your UI
        newOneToOneChatButton.on('click', function (event, theirUserId) {
            someChatObject.invite(theirUserId);
        });
    });
    

    【讨论】:

      猜你喜欢
      • 2018-01-16
      • 2016-08-24
      • 2012-09-24
      • 1970-01-01
      • 2020-08-28
      • 2015-12-05
      • 1970-01-01
      • 2019-09-22
      • 1970-01-01
      相关资源
      最近更新 更多