Sha256: 92a898bc1ca812459f54919f0b145417b0dd8b58dcca7f06e8aa7b6c0db00d33

Contents?: true

Size: 613 Bytes

Versions: 12

Compression:

Stored size: 613 Bytes

Contents

require 'rubygems'
require 'bundler/setup'
$:.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

12 entries across 12 versions & 1 rubygems

Version Path
sinatra-cometio-0.5.8 sample/bin/cui_chat_client.rb
sinatra-cometio-0.5.7 sample/bin/cui_chat_client.rb
sinatra-cometio-0.5.6 sample/bin/cui_chat_client.rb
sinatra-cometio-0.5.5 sample/bin/cui_chat_client.rb
sinatra-cometio-0.5.4 sample/bin/cui_chat_client.rb
sinatra-cometio-0.5.3 sample/bin/cui_chat_client.rb
sinatra-cometio-0.5.2 sample/bin/cui_chat_client.rb
sinatra-cometio-0.5.1 sample/bin/cui_chat_client.rb
sinatra-cometio-0.5.0 sample/bin/cui_chat_client.rb
sinatra-cometio-0.4.3 sample/bin/cui_chat_client.rb
sinatra-cometio-0.4.2 sample/bin/cui_chat_client.rb
sinatra-cometio-0.4.1 sample/bin/cui_chat_client.rb