【发布时间】:2015-05-28 04:35:39
【问题描述】:
我已经构建了一个小型聊天应用程序,如下所示: https://github.com/chrismccord/phoenix_chat_example/blob/master/web/channels/room_channel.ex
并且无法弄清楚如何在一个主题中向所有用户广播一条消息。在上面的应用程序中(没有像我使用的那样更新到 v0.13),我该怎么做?以下是我没有运气的尝试:
Phoenix.PubSub.broadcast Chat.PubSub, "new:msg", "hello from the console"
Phoenix.PubSub.broadcast Chat.Endpoint, "new:msg", "hello from the console"
Phoenix.PubSub.broadcast Chat.RoomChannel, "new:msg", "hello from the console"
它们都不起作用...其中一些抛出异常:(
【问题讨论】: