Sha256: 0860234509d794184f6884aaa76f52b6a0215ebaf8c57ddea1f515ea20b4b2c5

Contents?: true

Size: 2 KB

Versions: 1

Compression:

Stored size: 2 KB

Contents

sinatra-multi-screen
====================
Sinatra Plugin for Multi-Screen Application.


Installation
------------

    % gem install sinatra-multi-screen

Requirements
------------
* Ruby 1.8.7+ or 1.9.2+
* Sinatra 1.3.0+
* EventMachine
* jQuery
* [sinatra-comeio](http://shokai.github.com/sinatra-cometio)


Usage
-----

### Sinatra Setup

```ruby
require 'sinatra'
require 'sinatra/cometio'
require 'sinatra/multi_screen'

run Sinatra::Application
```
```html
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="<%= cometio_js %>"></script>
<script src="<%= multi_screen_js %>"></script>
```

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

Remote Side
```javascript
var io = new CometIO().connect();
var screen = new MultiScreen(io, {type: "remote"});
var tv = screen.tv;

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

TV Side
```html
<input type="button" id="btn" value="hello" />
```
```javascript
var io = new CometIO().connect();
var screen = new MultiScreen(io, {type: "tv"});

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

### TV --(push event)--> Remote

TV Side
```javascript
var io = new CometIO().connect();
var screen = new MultiScreen(io, {type: "tv"});

io.on("connect", function(session){
  screen.remote.push("change_color", {color: #FF0000"});  // push "change_color" event to Remote
};
```

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

Samples
-------
* https://github.com/shokai/sinatra-multi-screen/tree/master/sample
* http://multiscreen-youtube.herokuapp.com
* https://github.com/shokai/multiscreen-youtube-sample


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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sinatra-multi-screen-0.0.2 README.md