aboutsummaryrefslogtreecommitdiff
path: root/spec/startup_spec.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2020-07-14 21:32:36 -0400
committerAlexander Pickering <alex@cogarr.net>2020-07-14 21:32:36 -0400
commita7ff1b815987b0c1b3ded5701845e0eb52f0592c (patch)
treee5b199de0b986ab9fd802d68740da2611a524c64 /spec/startup_spec.lua
parent0f782391408321608c4742951df82fb2e714c5ae (diff)
downloadlua-nng-a7ff1b815987b0c1b3ded5701845e0eb52f0592c.tar.gz
lua-nng-a7ff1b815987b0c1b3ded5701845e0eb52f0592c.tar.bz2
lua-nng-a7ff1b815987b0c1b3ded5701845e0eb52f0592c.zip
Added pubsub methods
Add socket:subscribe() and socket:unsubscribe() for the pub/sub protocol.
Diffstat (limited to 'spec/startup_spec.lua')
-rw-r--r--spec/startup_spec.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/startup_spec.lua b/spec/startup_spec.lua
index 45fa996..dacf9e9 100644
--- a/spec/startup_spec.lua
+++ b/spec/startup_spec.lua
@@ -80,4 +80,17 @@ describe("nng",function()
assert(avg > 0.4)
assert(avg < 0.6)
end)
+ it("should be able to use publish and subscribe sockets to transfer information", function()
+ local s1 = assert(nng.pub0_open())
+ local s2 = assert(nng.sub0_open())
+ local s3 = assert(nng.sub0_open())
+ assert(s1:listen("ipc:///tmp/pub.ipc"))
+ assert(s2:subscribe(""))
+ assert(s3:subscribe(""))
+ assert(s2:dial("ipc:///tmp/pub.ipc"))
+ assert(s3:dial("ipc:///tmp/pub.ipc"))
+ assert(s1:send("hello 1"))
+ assert(s2:recv() == "hello 1")
+ assert(s3:recv() == "hello 1")
+ end)
end)