无法在带有Socket的聊天应用中发送消息?

时间:2018-11-16 22:30:33

标签: javascript node.js sockets websocket

我正在尝试通过我的应用发送消息,但是我总是在heroku中收到此错误。这是错误:

enter image description here

这是api代码:https://github.com/devslopes-learn/mac-chat-api

api代码段

    client.on('newMessage', function(messageBody, userId, channelId, userName, userAvatar, userAvatarColor) {
    //Create message

    console.log(messageBody);

    let newMessage = new Message({
    messageBody: messageBody,
    userId: userId,
    channelId: channelId,
    userName: userName,
    userAvatar: userAvatar,
    userAvatarColor: userAvatarColor
  });
    //Save it to database
    newMessage.save(function(msg){
      //Send message to those connected in the room
      console.log('new message sent');

      io.emit("messageCreated",  newMessage.messageBody, newMessage.userId, newMessage.channelId, newMessage.userName, newMessage.userAvatar, newMessage.userAvatarColor, newMessage.id, newMessage.timeStamp);
    });
  });

0 个答案:

没有答案