Sha256: fcb6373a04280ee4bca9c9a2451285d6620fd398e1c4c4aee0a695f527147061
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
require 'noam_lemma' # This is an example of a Ruby Lemma that publishes message and *also* uses the # "Guest" model of connection. This Lemma will advertise that it's available on # the local network and only begin subscribing to messages once a server # requests a connection from the Lemma. subscriber = Noam::Lemma.new('example-guest-subscriber', ["e3"], []) # Using the `advertise` method asks the Lemma to announce it's presence and # wait for a message from a server that may want to connect to it. # # The "local-test" parameter is the room name. Servers with a room name that's # the same as the Lemma's advertised room name will connect automatically. subscriber.advertise("") loop do # The `listen` method will return an Event object once one is received by the # Lemma. Until an event is heard, the `listen` method blocks. m = subscriber.listen # There's one special value that's returned from `listen`: the `:cancelled` # symbol. If this shows up, it means some one else has called the `stop` # method on the Lemma. if :cancelled == m puts "Done" break else puts "Read: #{m.event} -> #{m.value.inspect}" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
noam_lemma-0.2.1.2 | examples/free_guest_subscriber.rb |
noam_lemma-0.2.1.1 | examples/free_guest_subscriber.rb |
noam_lemma-0.2.1 | examples/free_guest_subscriber.rb |