The WebSocket framework implement inspired by ActionCable
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Tamashii Gem Version Build Status Test Coverage Code Climate

Tamashii is a package designed for IoT. You can write the WebSocket server and client easily by using this gem.


Add the following code to your Gemfile

gem 'tamashii'

And then execute:

$ bundle install

Or install it yourself with:

$ gem install tamashii


There are two section in Tamashii, Server and Client, is responsible for the WebSocket server and client, respectively.


Server section is a server designed based on Rack, it can not only be easily compatible with the web server, such as Puma, Passenger, but also be used as a module in the Rails and other projects.

To start the server, generate and add the following code to it.

require 'tamashii/server'


Then, you can start the server with:

$ rackup

If you want to start the server with other web server, such as Puma:

$ puma

You can refer to the project in tamashii-manager in the IoT server application.


In Tamashii, we only need to focus on how to connect with WebSocket users to exchange information, on the process of multi-process web server problems have been resolved in Tamashii.

We can create a Client object to handle the behavior of each user.

Tamashii::Server.config do |config|
  config.connection_class = Client

In Client , there are four events that need to be handled.

  • on_open : when the user is connected to the server
  • on_message : when the server receives the message from user
  • on_error : when the server gets an error
  • on_close : when the connection is shut down

In most cases, we only need to deal with parts of on_message , the other events can be handled as needed.

class Client
  def on_message(data)
    # Processing for the received Data (Binary)

By default Tamashii will broadcast the received message to other clients automatically.


The client is in another repository: tamashii-client


To get the source code

$ git clone

Initialize the development environment

$ ./bin/setup

Run the spec

$ rspec

Installation the version of development on localhost

$ bundle exec rake install


Please report to us on GitHub if there is any bug or suggested modified.

The project was developed by 5xruby Inc.