pusher.io 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6889eaecd6bcf3e410fb313692457af5222b51db
|
4
|
+
data.tar.gz: de9c124eb455d0e97ec462c1ef7f9920ec689ac1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c65cc45916eb74232c3cce397f185ca0ce71eac4504dc57e25d23c5ad036658fc9c17b77cc6c079ab858dae254e3a2e791c9c294c4ae6f72a8f87d2dc2ee1fd
|
7
|
+
data.tar.gz: fa8cfc61d010a388da25bf07dd564c1fd7e035a269932841a4b00ebf72eae5b632247ebeb627a87738db0484622757a100977f7e924bb7e347468021c39c643e
|
@@ -10,6 +10,12 @@ pusher = {}
|
|
10
10
|
this.socket = io.connect(socket_uri);
|
11
11
|
this.channelName = name;
|
12
12
|
this.subscribed = false;
|
13
|
+
|
14
|
+
var self = this;
|
15
|
+
this.socket.on('reconnect', function() {
|
16
|
+
self.subscribed = false;
|
17
|
+
self.subscribe();
|
18
|
+
});
|
13
19
|
}
|
14
20
|
|
15
21
|
Channel.prototype.subscribe = function() {
|
@@ -62,4 +68,4 @@ pusher = {}
|
|
62
68
|
return this.channel(name).unsubscribe();
|
63
69
|
}
|
64
70
|
|
65
|
-
}(window.jQuery);
|
71
|
+
}(window.jQuery);
|
@@ -1,8 +1,9 @@
|
|
1
|
-
require('js-yaml')
|
1
|
+
var yaml = require('js-yaml'),
|
2
|
+
fs = require('fs');
|
2
3
|
|
3
4
|
env = process.env.NODE_ENV || 'development'
|
4
5
|
|
5
|
-
var cfg =
|
6
|
+
var cfg = yaml.safeLoad(fs.readFileSync('./config/pusher.io.yml', 'utf8'))[env];
|
6
7
|
|
7
8
|
var crypto = require('crypto')
|
8
9
|
, hmac
|
@@ -26,12 +27,12 @@ if (cfg['ssl_key'] && cfg['ssl_cert']) {
|
|
26
27
|
key: fs.readFileSync(cfg['ssl_key']),
|
27
28
|
cert: fs.readFileSync(cfg['ssl_cert'])
|
28
29
|
}, app);
|
29
|
-
|
30
|
+
|
30
31
|
} else {
|
31
32
|
server = require('http').createServer(app);
|
32
33
|
}
|
33
34
|
|
34
|
-
io = require('socket.io')
|
35
|
+
io = require('socket.io')(server);
|
35
36
|
|
36
37
|
app.use(express.bodyParser());
|
37
38
|
|
@@ -56,38 +57,32 @@ app.post('/events', function(req, res) {
|
|
56
57
|
}
|
57
58
|
});
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
if (psignature(params) == handshakeData.query.signature) {
|
68
|
-
callback(null, true);
|
69
|
-
} else {
|
70
|
-
callback(null, false);
|
71
|
-
}
|
72
|
-
});
|
60
|
+
app.post('/users', function(req, res) {
|
61
|
+
if (req.body.key == cfg.key) {
|
62
|
+
res.send({
|
63
|
+
count: Object.keys(io.sockets.sockets).length
|
64
|
+
});
|
65
|
+
} else {
|
66
|
+
res.send(401);
|
67
|
+
}
|
73
68
|
});
|
74
69
|
|
75
|
-
io.
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
70
|
+
io.use(function (socket, next) {
|
71
|
+
var handshakeData = socket.handshake;
|
72
|
+
var params = [
|
73
|
+
'auth',
|
74
|
+
handshakeData.query.app_id,
|
75
|
+
handshakeData.query.timestamp,
|
76
|
+
cfg.key
|
77
|
+
];
|
78
|
+
if (psignature(params) == handshakeData.query.signature) {
|
79
|
+
next();
|
80
|
+
} else {
|
81
|
+
next(new Error('not authorized'));
|
82
|
+
}
|
88
83
|
});
|
89
84
|
|
90
|
-
io.
|
85
|
+
io.on('connection', function (socket) {
|
91
86
|
socket.on('subscribe', function(data) {
|
92
87
|
socket.join(data.channel);
|
93
88
|
});
|
@@ -97,4 +92,3 @@ io.sockets.on('connection', function (socket) {
|
|
97
92
|
});
|
98
93
|
|
99
94
|
server.listen(cfg.port);
|
100
|
-
console.log('started pusher.io ', env, cfg.host + ':' + cfg.port);
|
data/lib/pusher.io/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pusher.io
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yury
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Very basic implementation of pusherapp.com api subset on top of socket.io.
|
14
14
|
email:
|
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
version: '0'
|
52
52
|
requirements: []
|
53
53
|
rubyforge_project:
|
54
|
-
rubygems_version: 2.
|
54
|
+
rubygems_version: 2.5.1
|
55
55
|
signing_key:
|
56
56
|
specification_version: 4
|
57
57
|
summary: Socket.io for rails
|