Sha256: c56e313787548d85dfd4170be50557fb656fe397ba5f1f324ae52df44efdb2a7

Contents?: true

Size: 571 Bytes

Versions: 17

Compression:

Stored size: 571 Bytes

Contents

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

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

client = CometIO::Client.new('http://localhost:5000/cometio/io').connect

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

17 entries across 17 versions & 1 rubygems

Version Path
sinatra-cometio-0.3.9 sample/bin/cui_chat_client.rb
sinatra-cometio-0.3.8 sample/bin/cui_chat_client.rb
sinatra-cometio-0.3.7 sample/bin/cui_chat_client.rb
sinatra-cometio-0.3.6 sample/bin/cui_chat_client.rb
sinatra-cometio-0.3.5 sample/bin/cui_chat_client.rb
sinatra-cometio-0.3.4 sample/bin/cui_chat_client.rb
sinatra-cometio-0.3.3 sample/bin/cui_chat_client.rb
sinatra-cometio-0.3.2 sample/bin/cui_chat_client.rb
sinatra-cometio-0.3.1 sample/bin/cui_chat_client.rb
sinatra-cometio-0.3.0 sample/bin/cui_chat_client.rb
sinatra-cometio-0.2.0 sample/bin/cui_chat_client.rb
sinatra-cometio-0.1.9 sample/bin/cui_chat_client.rb
sinatra-cometio-0.1.8 sample/bin/cui_chat_client.rb
sinatra-cometio-0.1.7 sample/bin/cui_chat_client.rb
sinatra-cometio-0.1.6 sample/bin/cui_chat_client.rb
sinatra-cometio-0.1.5 sample/bin/cui_chat_client.rb
sinatra-cometio-0.1.4 sample/bin/cui_chat_client.rb