Sha256: 21e84fcf4173283478baa31e1baedf52d3de57a1fcbaebc1d8c6a28180401146

Contents?: true

Size: 589 Bytes

Versions: 2

Compression:

Stored size: 589 Bytes

Contents

require 'rubygems'
$:.unshift File.expand_path '../../lib', File.dirname(__FILE__)
require 'sinatra/cometio/client'

name = `whoami`.strip || 'shokai'

client = Sinatra::CometIO::Client.new('http://localhost:5000/cometio/io').connect
puts "timeout:#{client.timeout}"

client.on :connect do |session|
  puts "connect!! (session_id:#{session})"
end

client.on :chat do |data|
  puts "<#{data['name']}> #{data['message']}"
end

client.on :error do |err|
  STDERR.puts err
end

loop do
  line = STDIN.gets.strip
  next if line.empty?
  client.push :chat, {:message => line, :name => name}
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sinatra-cometio-0.6.0 sample/bin/cui_chat_client.rb
sinatra-cometio-0.5.9 sample/bin/cui_chat_client.rb