Sha256: a2ad6a6d70afa648ebfcab311ac1de5d8c8a80da1f8868fe63eb6e1018003c3a
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 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 speaking messages once a server requests a # connection from the Lemma. publisher = Noam::Lemma.new('example-guest-publisher', [], ["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. publisher.advertise("") seq = 0 e = "e3" loop do # Construct a value to send with the event. v = {"seq" => seq, "time" => Time.now.to_s} # If `speak` returns false, we're unable to speak the message likely because # the socket has closed. The connection would have to be restarted. unless publisher.speak(e, v) puts "Done" break end puts "Wrote: #{e} -> #{v.inspect}" seq += 1 # Sleep for a while so that we don't bog down the network. sleep(1) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
noam_lemma-0.2.1.2 | examples/free_guest_publisher.rb |
noam_lemma-0.2.1.1 | examples/free_guest_publisher.rb |
noam_lemma-0.2.1 | examples/free_guest_publisher.rb |