]> Entropealabs - wampex_router.git/commitdiff
add topic to published event
authorChristopher <chris@entropealabs.com>
Mon, 13 Apr 2020 20:10:08 +0000 (15:10 -0500)
committerChristopher <chris@entropealabs.com>
Mon, 13 Apr 2020 20:10:08 +0000 (15:10 -0500)
lib/router/session.ex
test/wampex_test.exs

index 1e6f5410165673e97a99c7bf135ab3fa365966f9..978144e93d603884331a6500b09a175bb2c6f8c4 100644 (file)
@@ -326,6 +326,7 @@ defmodule Wampex.Router.Session do
           pub_id = RealmSession.get_id()
 
           subs = RealmSession.subscriptions(db, realm, topic)
+          details = Map.put_new(opts, "topic", topic)
 
           Enum.each(subs, fn {id, {pid, node}} ->
             send(
@@ -335,7 +336,7 @@ defmodule Wampex.Router.Session do
                  publication_id: pub_id,
                  arg_list: arg_l,
                  arg_kw: arg_kw,
-                 details: opts
+                 details: details
                }, pid}
             )
           end)
index 7adb5be9f5390f7511916daff38cd4a5261ee0e9..c38ed57b617073a76a7bf41d6070fda010b186ab 100644 (file)
@@ -173,8 +173,8 @@ defmodule WampexTest do
       }
     )
 
-    assert_receive %Event{}, 2000
-    assert_receive %Event{}, 2000
-    assert_receive %Event{}, 2000
+    assert_receive %Event{details: %{"topic" => "com.data.test.temp"}}, 2000
+    assert_receive %Event{details: %{"topic" => "com.data.test.temp"}}, 2000
+    assert_receive %Event{details: %{"topic" => "com.data.test.temp"}}, 2000
   end
 end