Sha256: 362e4cf4b7c45b1ea82fe7f992e4cf1d94fdfa4b110bda56d5878e8da381674c

Contents?: true

Size: 746 Bytes

Versions: 21

Compression:

Stored size: 746 Bytes

Contents

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

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

EM::run do
  client = EM::WebSocketIO::Client.new('ws://localhost:8080').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

  client.on :disconnect do
    puts "disconnected!!"
  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

21 entries across 21 versions & 2 rubygems

Version Path
sinatra-rocketio-0.0.9 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.1.7 sample/bin/cui_chat_client.rb
sinatra-rocketio-0.0.8 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.1.6 sample/bin/cui_chat_client.rb
sinatra-rocketio-0.0.7 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.1.5 sample/bin/cui_chat_client.rb
sinatra-rocketio-0.0.6 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.1.4 sample/bin/cui_chat_client.rb
sinatra-rocketio-0.0.5 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.1.3 sample/bin/cui_chat_client.rb
sinatra-rocketio-0.0.4 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.1.2 sample/bin/cui_chat_client.rb
sinatra-rocketio-0.0.3 sample/bin/cui_chat_client.rb
sinatra-rocketio-0.0.2 sample/bin/cui_chat_client.rb
sinatra-rocketio-0.0.1 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.1.1 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.1.0 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.0.6 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.0.5 sample/bin/cui_chat_client.rb
sinatra-websocketio-0.0.4 sample/bin/cui_chat_client.rb