<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="157394" data-post-id="157394">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kokolegorille" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kokolegorille/120/4784_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kokolegorille
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Usually You would use the endpoint to broadcast anywhere from Phoenix…</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://phoenix.hexdocs.pm/Phoenix.Endpoint.html">
  <header class="source">

      <a href="https://phoenix.hexdocs.pm/Phoenix.Endpoint.html" target="_blank" rel="noopener nofollow">phoenix.hexdocs.pm</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://phoenix.hexdocs.pm/Phoenix.Endpoint.html" target="_blank" rel="noopener nofollow">Phoenix.Endpoint — Phoenix v1.8.8</a></h3>



  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>But in your case, You might as well create a channel, and use Phoenix pubsub directly.</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://phoenix.hexdocs.pm/1.1.3/Phoenix.PubSub.html">
  <header class="source">

      <a href="https://phoenix.hexdocs.pm/1.1.3/Phoenix.PubSub.html" target="_blank" rel="noopener nofollow">phoenix.hexdocs.pm</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://phoenix.hexdocs.pm/1.1.3/Phoenix.PubSub.html" target="_blank" rel="noopener nofollow">Phoenix.PubSub – Phoenix v1.1.3</a></h3>



  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<p>What I usually do is create a notifier module, like this…</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule KokoWeb.Notifier do
  require Logger
  alias KokoWeb.Endpoint

  def notify(%{payload: %{id: id, user_id: user_id}, type: :game_left}) do
    Endpoint.broadcast!("world:#{id}", "world_left", %{id: user_id})
  end

  def notify(%{payload: %{from: from, to: to}, type: :ping}) do
    Endpoint.broadcast!("user:#{to}", "ping", %{from: from})
  end

  def notify(message) do
    Logger.debug(fn -&gt; "Unknown notification #{inspect(message)}" end)
  end
end
</code></pre>
<p>I can use this module from my server.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="157394" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/looking-to-create-a-simple-function-in-phoenix/27983/8">Post #7</a>
	                </div>
	            </div>
              <div id="likers-container-157394" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157394"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #7"></div>
  </section>
</div>
    <div class="postbit" id="157391" data-post-id="157391">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="phanendery" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  phanendery
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>This video seems to be going over the working chat I have already created. So how would I send a message from my server and make it display on my browser window?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="157391" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/looking-to-create-a-simple-function-in-phoenix/27983/7">Post #6</a>
	                </div>
	            </div>
              <div id="likers-container-157391" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157391"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #6"></div>
  </section>
</div>
    <div class="postbit" id="157383" data-post-id="157383">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="wolfiton" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/wolfiton/120/15884_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  wolfiton
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Does this help <a href="https://www.youtube.com/watch?v=KAqUy3nsXfg" rel="noopener nofollow ugc">https://www.youtube.com/watch?v=KAqUy3nsXfg</a>?</p>
<p>Also this <a href="https://elixirgirls.com/guides/channels.html" class="inline-onebox" rel="noopener nofollow ugc">elixirgirls.com — Domain For Sale for $2,788 | Unstoppable Domains</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="157383" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/looking-to-create-a-simple-function-in-phoenix/27983/6">Post #5</a>
	                </div>
	            </div>
              <div id="likers-container-157383" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157383"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #5"></div>
  </section>
</div>
    <div class="postbit" id="157378" data-post-id="157378">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="phanendery" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  phanendery
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I ended up setting up a simple channel chat room following the guide but I am stuck on if I create a broadcast (message) function in my test.ex, how would i connect this function to my channel to display message on my browser window?</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="157378" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/looking-to-create-a-simple-function-in-phoenix/27983/5">Post #4</a>
	                </div>
	            </div>
              <div id="likers-container-157378" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157378"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #4"></div>
  </section>
</div>
    <div class="postbit" id="157167" data-post-id="157167">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="patrickdm" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/patrickdm/120/7579_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  patrickdm
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Channels seems a good solution for your requirements, I’d suggest you to make a fresh new project in order to learn about them, in isolation. (you dont need a db / ecto for that.)<br>
<a class="mention" href="/u/axelson" rel="nofollow">@axelson</a> linked the guide, which is the must-read starting point and contains a very clear tutorial. With it I’d say you’re half way through <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"> Enjoy the challenge!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="157167" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/looking-to-create-a-simple-function-in-phoenix/27983/4">Post #3</a>
	                </div>
	            </div>
              <div id="likers-container-157167" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157167"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #3"></div>
  </section>
</div>
    <div class="postbit" id="157164" data-post-id="157164">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="phanendery" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  phanendery
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Hi!</p>
<p>I was wondering if you maybe give me some more steps to follow? I am pretty new to this and would like to understand on how I would get this rolling!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="157164" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/looking-to-create-a-simple-function-in-phoenix/27983/3">Post #2</a>
	                </div>
	            </div>
              <div id="likers-container-157164" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157164"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #2"></div>
  </section>
</div>
    <div class="postbit" id="157082" data-post-id="157082">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="axelson" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/axelson/120/26351_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  axelson
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Scenic Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Seems like a very specific problem statement!</p>
<p>I think you’d be well served using <a href="https://hexdocs.pm/phoenix/channels.html" rel="nofollow">Phoenix Channels</a> along with your Endpoint’s <a href="https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#c:broadcast/3" rel="nofollow">broadcast/3</a> function.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="157082" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/looking-to-create-a-simple-function-in-phoenix/27983/2">Post #1</a>
	                </div>
	            </div>
              <div id="likers-container-157082" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="157082"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-first-post cat-first-post" title="First post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>