Sha256: 72e5a8027d182447d2da693733ca16299308cf2f9bfab34a05cf3117d8b8f54b
Contents?: true
Size: 789 Bytes
Versions: 2
Compression:
Stored size: 789 Bytes
Contents
#!/usr/bin/env ruby require 'rubygems' require 'bundler/setup' $:.unshift File.expand_path '../../lib', File.dirname(__FILE__) require 'sinatra/rocketio/client' name = `whoami`.strip || 'shokai' url = ARGV.shift || 'http://localhost:5000' type = ARGV.shift || :websocket io = Sinatra::RocketIO::Client.new(url, :type => type).connect #io = Sinatra::RocketIO::Client.new('http://localhost:5000', :type => :comet).connect io.on :connect do |session| puts "#{io.type} connect!! (session_id:#{session})" end io.on :chat do |data| puts "<#{data['name']}> #{data['message']}" end io.on :error do |err| STDERR.puts err end io.on :disconnect do puts "disconnected!!" end loop do line = STDIN.gets.strip next if line.empty? io.push :chat, {:message => line, :name => name} end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sinatra-rocketio-0.1.2 | sample/bin/cui_chat_client.rb |
sinatra-rocketio-0.1.1 | sample/bin/cui_chat_client.rb |