dongsuoying9059 2016-10-17 17:40
浏览 19

当有人发送消息时,为每个人更新聊天

I am making a chatroom that uses ajax in javascript to update and send messages. I was wondering if it was possible to do something like this -

If a chat message was sent (chat.send), then make everyone else in the chatroom do a chat update (chat.update).

I'm not sure where to start on this.

  • 写回答

1条回答 默认 最新

  • dongyong5912 2016-10-17 17:50
    关注

    Chatroom in the browser? Well it sounds like you are exploring your options so why not look at socket.io? link to socket io chat example. Socket io makes two way communication between the server and client browser possible (provides an interface for sockets), which means you can chat in real time with others, and it works quite intiutively.

    Otherwise, if you want to use Ajax, you can use polling. Other users will poll for updates (ask the server for status updates at time intervals) and if one of the users made a chat message they'll receive the chat message while polling from the server.

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100