Giter VIP home page Giter VIP logo

socketio-client's Introduction

Simple Socket IO client

Quick and kinda dirty socket.io client using web sockets

Features

This client currently supports:

  • Listeners for all 9 possible message
  • Send messages of the type:
    • message
    • json
    • event

How to use:

require 'SocketIO'

client = SocketIO.connect("http://localhost") do
  before_start do
    on_message {|message| puts "incoming message: #{message}"}
    on_event('news') { |data| puts data.first} # data is an array fo things.
  end

end

Sync vs Async

You can start the socket io syncronously and then continue with your work this crates threads so be careful.

require 'SocketIO'

client = SocketIO.connect("http://localhost", sync: true) do
  before_start do
    on_message {|message| puts message}
    on_disconnect {puts "I GOT A DISCONNECT"}
  end

  after_start do
    emit("loadLogs", "/var/www/rails_app/log/production.log")
  end
end

puts "socket still running"
loop do
  sleep 10
  puts 'zzz'
end

Examples

examples can be found in the examples/ folder. A corrosponding server can be found in the examples/servers

socketio-client's People

Contributors

cvhoang avatar douglasroeder avatar

Watchers

James Cloos avatar Kirill Alhimov 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.