我想在我的 (Rails) 网站上添加简单的聊天和协作功能。 TogetherJS是 Mozilla 用于实时协作的开源 JavaScript 库。它可以很容易地放入网站中并且可以正常工作。
但是,要与某人协作,您需要向他们发送一个链接。网站上的用户不知道谁在访问,因此他们无法向其他人发送链接。如何解决这个问题?
(一个想法是在 TogetherJS 上创建一个 session ,然后向站点上的每个人显示该链接,以便他们可以根据需要加入。)
最佳答案
TogetherJS 有一个创建房间的选项,看起来它允许我正在寻找的聊天。 documentation没有详细介绍,但是 togetherjs.js source code有帮助的评论:
// Used to auto-start TogetherJS with a {prefix: pageName, max: participants}
// Also with findRoom: "roomName" it will connect to the given room name
findRoom: null,
他们还有example apps展示其用途:
<script>
TogetherJSConfig_findRoom = {prefix: "togetherjsmadlibs", max: 5};
TogetherJSConfig_autoStart = true;
TogetherJSConfig_suppressJoinConfirmation = true;
TogetherJSConfig_storagePrefix = "tjs_madlibs";
</script>
关于javascript - 如何将 TogetherJS 用作聊天应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20807500/