Sha256: 3a6cb94d976338f2478e0c70cc210081e67a1e5d8cf9d4644dcb400049c32273
Contents?: true
Size: 611 Bytes
Versions: 1
Compression:
Stored size: 611 Bytes
Contents
module Netz class Broadcaster attr_accessor :remote_clients, :command_channel def initialize @remote_clients = [] end def run Thread.new do loop do command = @command_channel.pop push_to_peers command if command.local? end end end def push_to_peers(command) # TODO add command buffering? command.extend(CommandSerializer) # write to clients msg = command.serialize puts msg @remote_clients.each do |rc| rc.write [msg.length].pack("S") rc.write msg end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
netz-0.0.1 | lib/netz/broadcaster.rb |