Sinatra Multi Screen banner
shokai shokai

Sinatra Multi Screen

Development community

Description

Sinatra Plugin for Multi-Screen Application.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

sinatra-multi-screen

Sinatra Plugin for Multi-Screen Application.

Installation

% gem install sinatra-multi-screen

Requirements

Usage

Sinatra Setup

require 'sinatra'
require 'sinatra/cometio'
require 'sinatra/multi_screen'

run Sinatra::Application

">
">

Remote --(dispatch UI Event)--> TV

Remote Side

var io = new CometIO().connect();
var screen = new MultiScreen(io, {type: "remote", channel: "1"});
var tv = screen.tv;

io.on("connect", function(session){
  tv.$("#btn").click();  // dispatch CLICK event on TV Side
};

tv.on("ui_event", function(data){  // UI Event echo back from TV
  alert(data.event+' was dispatched on TV-side '+data.selector);
});

TV Side

var io = new CometIO().connect();
var screen = new MultiScreen(io, {type: "tv", channel: "1"});
var remote = screen.remote;

$(function(){
  $("#btn").click(function(e){ // regist click event
    alert("hello!!");
  });
});

TV --(push event)--> Remote

TV Side

remote.push("change_color", {color: #FF0000"});  // push "change_color" event to Remote

Remote Side

tv.on("change_color", function(data){ // regist "change_color" event
  $("body").css("background-color", data.color);
});

Remote --(push event)--> TV

Remote Side

tv.push("mode", "fullscreen");  // push "mode" to TV

TV Side

remote.on("mode", function(data){
  console.log(data);
});

Events on Server

Sinatra Side

MultiScreen.on :connect do |client|
  puts "new client #{client.inspect}"