Sha256: 3886dade45fe784c130133541def2d86cc96cb979153ac4b5876267d9976aa09

Contents?: true

Size: 638 Bytes

Versions: 6

Compression:

Stored size: 638 Bytes

Contents

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

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

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

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

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
em-cometio-client-0.0.6 sample/cui_chat_client.rb
em-cometio-client-0.0.5 sample/cui_chat_client.rb
em-cometio-client-0.0.4 sample/cui_chat_client.rb
em-cometio-client-0.0.3 sample/cui_chat_client.rb
em-cometio-client-0.0.2 sample/cui_chat_client.rb
em-cometio-client-0.0.1 sample/cui_chat_client.rb