plezi 0.14.4 → 0.14.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,34 @@
1
1
  # Replace this sample with real code.
2
2
  class RootController
3
- # HTTP
4
- def index
5
- # any String returned will be appended to the response. We return a String.
6
- render 'welcome'
7
- end
3
+ # HTTP
4
+ def index
5
+ # any String returned will be appended to the response. We return a String.
6
+ render 'welcome'
7
+ end
8
8
 
9
- # Websockets
10
- def on_message(data)
11
- data = ERB::Util.html_escape data
12
- print data
13
- broadcast :print, data
14
- end
9
+ # Websockets
10
+ def on_message(data)
11
+ data = ERB::Util.html_escape data
12
+ print data
13
+ broadcast :print, data
14
+ end
15
15
 
16
- def on_open
17
- print 'Welcome to appname!'
18
- @handle = params['id'.freeze] || 'Somebody'
19
- broadcast :print, "#{ERB::Util.html_escape @handle} joind us :-)"
20
- end
16
+ def on_open
17
+ print 'Welcome to appname!'
18
+ @handle = params['id'.freeze] || 'Somebody'
19
+ broadcast :print, "#{ERB::Util.html_escape @handle} joind us :-)"
20
+ end
21
21
 
22
- def on_close
23
- broadcast :print, "#{@handle} left us :-("
24
- end
22
+ def on_close
23
+ broadcast :print, "#{@handle} left us :-("
24
+ end
25
25
 
26
- protected
26
+ protected
27
27
 
28
- # write is inherites when a Websocket connection is opened.
29
- #
30
- # Inherited functions aren't exposed (for our security), so we need to wrap it.
31
- def print(data)
32
- write data
33
- end
28
+ # write is inherites when a Websocket connection is opened.
29
+ #
30
+ # Inherited functions aren't exposed (for our security), so we need to wrap it.
31
+ def print(data)
32
+ write data
33
+ end
34
34
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  ## Set environment, working directory, load gems and create logs
4
- ENV['ENV'] ||= ENV['RACK_ENV'] # production ENV will render SASS as compressed.
4
+ ENV['ENV'] ||= ENV['RACK_ENV'] ||= ENV['RAILS_ENV'] # production ENV will render SASS as compressed.
5
5
  ## Using pathname extentions for setting public folder
6
6
  require 'pathname'
7
7
  ## Set up root object, it might be used by the environment and\or the plezi extension gems.
@@ -5,54 +5,61 @@
5
5
 
6
6
  // For an auto-dispatch, JSON implementation, consoder using the PleziClient.
7
7
 
8
- // Your websocket URI should be an absolute path. The following sets the base URI.
8
+ // Your websocket URI should be an absolute path. The following sets the base
9
+ // URI.
9
10
  // remember to update to the specific controller's path to your websocket URI.
10
- var ws_controller_path = windselfow.location.pathname; // change to '/controller/path'
11
- var ws_uri = (self.location.protocol.match(/https/) ? 'wss' : 'ws') + '://' + self.document.location.host + ws_controller_path
11
+ var ws_controller_path =
12
+ windselfow.location.pathname; // change to '/controller/path'
13
+ var ws_uri = (self.location.protocol.match(/https/) ? 'wss' : 'ws') + '://' +
14
+ self.document.location.host + ws_controller_path;
12
15
  // websocket variable.
13
- var websocket = NaN
16
+ var websocket = NaN;
14
17
  // count failed attempts
15
- var websocket_fail_count = 0
18
+ var websocket_fail_count = 0;
16
19
  // to limit failed reconnection attempts, set this to a number.
17
- var websocket_fail_limit = NaN
18
- // to offer some space between reconnection attempts, set this interval in miliseconds.
19
- var websocket_reconnect_interval = 250
20
+ var websocket_fail_limit = NaN;
21
+ // to offer some space between reconnection attempts, set this interval in
22
+ // miliseconds.
23
+ var websocket_reconnect_interval = 250;
20
24
 
21
- function init_websocket()
22
- {
23
- if(websocket && websocket.readyState == 1) return true; // console.log('no need to renew socket connection');
24
- websocket = new WebSocket(ws_uri);
25
- websocket.onopen = function(e) {
26
- // reset the count.
27
- websocket_fail_count = 0
28
- // what do you want to do now?
29
- };
25
+ function init_websocket() {
26
+ if (websocket && websocket.readyState == 1)
27
+ return true; // console.log('no need to renew socket connection');
28
+ websocket = new WebSocket(ws_uri);
29
+ websocket.onopen = function(e) {
30
+ // reset the count.
31
+ websocket_fail_count = 0;
32
+ // what do you want to do now?
33
+ };
30
34
 
31
- websocket.onclose = function(e) {
32
- // If the websocket repeatedly you probably want to report an error
33
- if(!isNaN(websocket_fail_limit) && websocket_fail_count >= websocket_fail_limit) {
34
- // What to do if we can't reconnect so many times?
35
- return
36
- };
37
- // you probably want to reopen the websocket if it closes.
38
- if(isNaN(websocket_fail_limit) || (websocket_fail_count <= websocket_fail_limit) ) {
39
- // update the count
40
- websocket_fail_count += 1;
41
- // try to reconect
42
- setTimeout( init_websocket, websocket_reconnect_interval);
43
- };
44
- };
45
- websocket.onerror = function(e) {
46
- // update the count.
47
- websocket_fail_count += 1
48
- // what do you want to do now?
49
- };
50
- websocket.onmessage = function(e) {
51
- // what do you want to do now?
52
- console.log(e.data);
53
- // to use JSON, use:
54
- // msg = JSON.parse(e.data); // remember to use JSON also in your Plezi controller.
55
- };
35
+ websocket.onclose = function(e) {
36
+ // If the websocket repeatedly you probably want to report an error
37
+ if (!isNaN(websocket_fail_limit) &&
38
+ websocket_fail_count >= websocket_fail_limit) {
39
+ // What to do if we can't reconnect so many times?
40
+ return;
41
+ };
42
+ // you probably want to reopen the websocket if it closes.
43
+ if (isNaN(websocket_fail_limit) ||
44
+ (websocket_fail_count <= websocket_fail_limit)) {
45
+ // update the count
46
+ websocket_fail_count += 1;
47
+ // try to reconect
48
+ setTimeout(init_websocket, websocket_reconnect_interval);
49
+ };
50
+ };
51
+ websocket.onerror = function(e) {
52
+ // update the count.
53
+ websocket_fail_count += 1;
54
+ // what do you want to do now?
55
+ };
56
+ websocket.onmessage = function(e) {
57
+ // what do you want to do now?
58
+ console.log(e.data);
59
+ // to use JSON, use:
60
+ // msg = JSON.parse(e.data); // remember to use JSON also in your Plezi
61
+ // controller.
62
+ };
56
63
  }
57
64
  // setup the websocket connection once the page is done loading
58
- self.addEventListener("load", init_websocket, false);
65
+ self.addEventListener("load", init_websocket, false);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plezi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.4
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-13 00:00:00.000000000 Z
11
+ date: 2017-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iodine
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '0.2'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.2.7
22
+ version: 0.2.14
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '0.2'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 0.2.7
32
+ version: 0.2.14
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rack
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -50,28 +50,28 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1.13'
53
+ version: '1.14'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1.13'
60
+ version: '1.14'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '10.0'
67
+ version: '11.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '10.0'
74
+ version: '11.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: minitest
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +105,7 @@ files:
105
105
  - bin/console
106
106
  - bin/hello_world
107
107
  - bin/setup
108
+ - bin/ws_shootout
108
109
  - exe/plezi
109
110
  - lib/plezi.rb
110
111
  - lib/plezi/activation.rb