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: 7e49823399d6a2b8ff8c960a5894f4003e5aa7b7
4
- data.tar.gz: d766ee6375e50dce8aca65ffa20950010023b6ba
3
+ metadata.gz: 6889eaecd6bcf3e410fb313692457af5222b51db
4
+ data.tar.gz: de9c124eb455d0e97ec462c1ef7f9920ec689ac1
5
5
  SHA512:
6
- metadata.gz: 877e574004e7334f94557472bf26fd6d1cb7e1bb9a71faff01e4ed1eff910882ab6e824e89b0cf14a2a67fbf095ed1c68c5a5ab406d94d6a0882a6272bdf3eaa
7
- data.tar.gz: 151525d6cba8613be5d2a91b45fb25721287914cc984ccc39a490275c2d7bb0d3a510ee3ab02c2ff846bc407f90742d0d28373b40761414cf5d7d56fcb26f7ce
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);
@@ -5,7 +5,7 @@
5
5
  "private": true,
6
6
  "dependencies": {
7
7
  "express": "3.x",
8
- "socket.io": "0.9.x",
8
+ "socket.io": "1.4.5",
9
9
  "js-yaml": "*"
10
10
  }
11
- }
11
+ }
@@ -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 = require('./config/pusher.io.yml')[env];
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').listen(server);
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
- io.configure(function () {
60
- io.set('authorization', function (handshakeData, callback) {
61
- var params = [
62
- 'auth',
63
- handshakeData.query.app_id,
64
- handshakeData.query.timestamp,
65
- cfg.key
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.configure('production', function(){
76
- io.enable('browser client minification'); // send minified client
77
- io.enable('browser client etag'); // apply etag caching logic based on version number
78
- io.enable('browser client gzip'); // gzip the file
79
- io.set('log level', 1);
80
-
81
- io.set('transports', [
82
- 'websocket'
83
- , 'flashsocket'
84
- , 'htmlfile'
85
- , 'xhr-polling'
86
- , 'jsonp-polling'
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.sockets.on('connection', function (socket) {
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);
@@ -1,5 +1,5 @@
1
1
  module Pusher
2
2
  module IO
3
- VERSION = "0.0.5"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
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.5
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: 2014-04-27 00:00:00.000000000 Z
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.2.0
54
+ rubygems_version: 2.5.1
55
55
  signing_key:
56
56
  specification_version: 4
57
57
  summary: Socket.io for rails