Sha256: deeba8a7cc4ee0b0a743664a84b0a980eb422040b976808406caa45d403f171e
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 KB
Contents
#require 'yaml' require 'journeta/asynchronous' module Journeta class EventBroadcaster < Journeta::Asynchronous attr_accessor :thread def go #(engine) address = @engine.presence_address port = @engine.presence_port delay = @engine.presence_period uuid = @engine.uuid peer_port = @engine.peer_port groups = @engine.groups begin socket = UDPSocket.open if PLATFORM[/linux/i] socket.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEADDR, [1].pack("i_") ) else # socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, [1].pack('i')) # Preston's original config for OS X. socket.setsockopt( Socket::SOL_SOCKET, Socket::SO_REUSEPORT, [1].pack("i_") ) # Remi's suggested default. end loop do putsd "Sending presence event." note = PresenceMessage.new uuid, peer_port, groups socket.send(note.to_yaml, 0, address, port) sleep delay end ensure putsd "Closing event broadcaster socket." socket.close end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
journeta-0.0.3 | lib/journeta/presence_broadcaster.rb |
journeta-0.0.4 | lib/journeta/presence_broadcaster.rb |
journeta-0.0.5 | lib/journeta/presence_broadcaster.rb |