Sha256: 3c41730f3be2429aa900c9cf53d223d60998ab8a8de519b1fb0cd48aa8326bc2

Contents?: true

Size: 542 Bytes

Versions: 1

Compression:

Stored size: 542 Bytes

Contents

module Netz
  class Catcher
    attr_accessor :remote_clients, :command_channel

    def initialize()
      @remote_clients = []
    end

    def run
      #thread per client?
      @remote_clients.each do |rc|
        Thread.new do
          loop do
            read_command(rc)
          end
        end
      end
    end

    def read_command(remote_client)
      length = remote_client.recvfrom(2)[0].unpack("S")[0]
      cmd = CommandSerializer.deserialize(remote_client.recvfrom(length))
      @command_channel << cmd 
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
netz-0.0.1 lib/netz/catcher.rb