sinatra-cometio 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/lib/js/cometio.js +4 -2
- data/lib/sinatra-cometio/application.rb +3 -2
- data/lib/sinatra-cometio/version.rb +1 -1
- data/lib/sinatra/cometio/client.rb +4 -2
- data/test/test_cometio.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2d4bcecc45017cc73256cad7afa8424be83162c
|
4
|
+
data.tar.gz: d722c7b6be85852d63d1b011ce97fa8d1c293138
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3faffbfe215f98cd092e2ce48a9ca849c16dff81de741030b71936988069fbd620605e0d762ccb68d19f57b734600ee693beec8b8d6f0ae248fe64307f093508
|
7
|
+
data.tar.gz: b795964ad56a975f1ee07993c6130efdd73cb80c439db4bae11aeb63be86b9638f2a6da2fb66828b7939feea5a13f24a9af17722274ac918438ae74de2fb4743
|
data/History.txt
CHANGED
data/lib/js/cometio.js
CHANGED
@@ -9,8 +9,10 @@ var CometIO = function(){
|
|
9
9
|
var flush = function(){
|
10
10
|
if(!running || post_queue.length < 1) return;
|
11
11
|
var post_data = {
|
12
|
-
|
13
|
-
|
12
|
+
json: JSON.stringify({
|
13
|
+
session: self.session,
|
14
|
+
events: post_queue
|
15
|
+
})
|
14
16
|
};
|
15
17
|
$.ajax(
|
16
18
|
{
|
@@ -41,9 +41,10 @@ module Sinatra
|
|
41
41
|
end
|
42
42
|
|
43
43
|
app.post '/cometio/io' do
|
44
|
-
|
44
|
+
data = JSON.parse params[:json] rescue halt 500, 'JSON parse error'
|
45
|
+
from = data['session']
|
45
46
|
halt 400, 'no session' if !from or from.empty?
|
46
|
-
events =
|
47
|
+
events = data['events']
|
47
48
|
halt 400, 'no data' unless [Hash, Array].include? events.class
|
48
49
|
events = events.keys.sort.map{|i| events[i] } if events.kind_of? Hash
|
49
50
|
EM::defer do
|
@@ -23,8 +23,10 @@ module Sinatra
|
|
23
23
|
|
24
24
|
def push(type, data)
|
25
25
|
post_data = {
|
26
|
-
:
|
27
|
-
|
26
|
+
:json => {
|
27
|
+
:session => @session,
|
28
|
+
:events => [{:type => type, :data => data}]
|
29
|
+
}.to_json
|
28
30
|
}
|
29
31
|
begin
|
30
32
|
res = HTTParty.post @url, :timeout => 10, :body => post_data
|
data/test/test_cometio.rb
CHANGED