Project

tuppari

0.0
No commit activity in last 3 years
No release in over 3 years
Tuppari is an experimental implementation of unbreakable message broadcasting system using WebSocket and Amazon Web Services by @hakobera.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

= 1.7.4
 Project Readme

Tuppari Client for Ruby

About Tuppari

Tuppari is an experimental implementation of an unbreakable message broadcasting system using WebSockets and Amazon Web Services by @hakobera.

https://github.com/tuppari/tuppari

https://github.com/tuppari/tuppari-servers

Tuppari for Ruby Developers

You can easily build a Tuppari application by just using the Ruby API. Let's get started now!

Gemfile

Prepare your Gemfile as follows:

source 'https://rubygems.org'

gem 'tuppari'

Getting Started

Invoke bundle console to try Tuppari:

require 'tuppari'

Tuppari.create_account(YOUR_ID, PASSWORD)

tuppari = Tuppari.login(YOUR_ID, PASSWORD)

application = tuppari.create_application('first-tuppari')

open('tuppari.html', 'w') do |f|
  html = <<"EOF"
<html>
  <head>
  <script src="http://cdn.tuppari.com/0.2.0/tuppari.min.js"></script>
  <script>
    var client, channel;
    client = tuppari.createClient({applicationId: '#{application.id}'});
    channel = client.subscribe('ch');
    channel.bind('update', function (msg) {
      console.log(msg);
    });
  </script>
  </head>
  <body>Check JavaScript console.</body>
</html>
EOF
  f.write(html)
end

#
# [notice] Please open this 'tuppari.html' file in browser.
#

tuppari.application = application # or tuppari.load_application_by_name('first-tuppari') 

tuppari.publish_message(
  :channel => 'ch',
  :event => 'update',
  :message => "Hello, Tuppari! (#{Time.now})"
)

Publishing Messages

Tuppari account authentication is not needed for publishing messages. However, the following values for the target application are required:

  • application_id
  • access_key_id (for the application)
  • access_secret_key (for the application)
application = Tuppari::Application.new(
  :id                => '4032236d-699a-4599-9405-xxxxxxxxxxxx', 
  :access_key_id     => 'b49049f9-e055-4fa5-925b-xxxxxxxxxxxx', 
  :access_secret_key => 'c01a3a31-92cd-4bf9-a238-xxxxxxxxxxxx'
) # or application = tuppari.get_application('first-tuppari') 

Tuppari.publish_message(
  :application => application,
  :channel => 'ch',
  :event => 'update',
  :message => "Hello, Tuppari! (#{Time.now})"
)

License

The MIT License