Sha256: 779255550eb1fffb606ee4b109a2d0da5b6e73a4900abef43f1e6d620c429676

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

#!/usr/bin/env ruby
require "rubygems"
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
require 'em-rocketio-linda-client'

url = ARGV.empty? ? "http://linda.shokai.org" : ARGV.shift

EM::run do
  client = EM::RocketIO::Linda::Client.new url
  ts = client.tuplespace["test_spae"]

  client.io.on :connect do
    puts "connect #{client.io.type} (#{client.io.session})"
    ts.write [1,2,3]
    ts.write [1,2,3,4]
    ts.write [1,2,3,4,"abc"]

    EM::defer do
      loop do
        tuple = ts.take [1,2]  ## read tuple([1,2]) and delete
        puts "blocking take #{tuple}"
        list = ts.list [1,2]
        puts "#{list.size} tuples exists."
      end
    end

    EM::add_periodic_timer 1 do
      ts.write [1,2, Time.now]
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
em-rocketio-linda-client-1.1.1 sample/sample_blocking.rb