Giter Site home page Giter Site logo

tnj / ruby-socket.io-client-simple Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shokai/ruby-socket.io-client-simple

0.0 2.0 0.0 119 KB

A simple ruby client for node.js's socket.io. Supports only WebSocket.

Home Page: https://rubygems.org/gems/socket.io-client-simple

License: MIT License

Ruby 100.00%

ruby-socket.io-client-simple's Introduction

SocketIO::Client::Simple

A simple ruby client for Node.js's Socket.IO v1.3.x, Supports only WebSocket.

Travis-CI Build Status

Install

gem install

% gem install socket.io-client-simple  # latest version, supports Socket.IO v1.3.x

or use Gemfile with Bundler

gem 'socket.io-client-simple', '< 1.0'  # for Socket.IO v0.9.x
gem 'socket.io-client-simple'           # for Socket.IO v1.3.x

Usage

samples/sample.rb

require 'rubygems'
require 'socket.io-client-simple'

socket = SocketIO::Client::Simple.connect 'http://localhost:3000'

## connect with parameter
socket = SocketIO::Client::Simple.connect 'http://localhost:3000', :foo => "bar"

socket.on :connect do
  puts "connect!!!"
end

socket.on :disconnect do
  puts "disconnected!!"
end

socket.on :chat do |data|
  puts "> " + data['msg']
end

socket.on :error do |err|
  p err
end

puts "please input and press Enter key"
loop do
  msg = STDIN.gets.strip
  next if msg.empty?
  socket.emit :chat, {:msg => msg, :at => Time.now}
end

sample.rb works with samples/chat_server.coffee.

start chat server

% npm install
% coffee samples/chat_server.coffee

=> chat server start at localhost:3000

ruby sample.rb

% ruby samples/sample.rb

Test

% gem install bundler
% bundle install
% npm install
% bundle exec rake test

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

ruby-socket.io-client-simple's People

Contributors

mallowlabs avatar shokai avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.