@freesignal/socketio 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/server.js +6 -14
  2. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -16,15 +16,6 @@
16
16
  * You should have received a copy of the GNU General Public License
17
17
  * along with this program. If not, see <https://www.gnu.org/licenses/>
18
18
  */
19
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
20
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21
- return new (P || (P = Promise))(function (resolve, reject) {
22
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
23
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
25
- step((generator = generator.apply(thisArg, _arguments || [])).next());
26
- });
27
- };
28
19
  import { Server } from 'socket.io';
29
20
  import { FreeSignalSocketio, TransportEvent } from "./base.js";
30
21
  export class FreeSignalServer extends FreeSignalSocketio {
@@ -56,7 +47,7 @@ export class FreeSignalServer extends FreeSignalSocketio {
56
47
  origin: (origin, callback) => callback(null, origin)
57
48
  }
58
49
  });
59
- this.wss.on('connection', (socket) => __awaiter(this, void 0, void 0, function* () {
50
+ this.wss.on('connection', (socket) => {
60
51
  const userId = socket.handshake.auth.userId;
61
52
  if (!userId) {
62
53
  socket.disconnect();
@@ -67,13 +58,14 @@ export class FreeSignalServer extends FreeSignalSocketio {
67
58
  socket.on(TransportEvent.MESSAGE, (data) => this.open(data));
68
59
  socket.on('disconnect', () => this.connections.delete(userId));
69
60
  socket.emit(TransportEvent.HANDSHAKE, this.userId.toString());
70
- if (!(yield this.sessions.has(userId))) {
71
- this.sendBootstrap(userId);
61
+ const sessionTag = this.users.get(userId);
62
+ if (sessionTag && this.sessions.has(sessionTag)) {
63
+ this.sendHandshake(userId);
72
64
  }
73
65
  else {
74
- this.sendHandshake(userId);
66
+ this.sendBootstrap(userId);
75
67
  }
76
- }));
68
+ });
77
69
  return this;
78
70
  }
79
71
  close() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@freesignal/socketio",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Socket.io trasnport package for FreeSignal protocol",
5
5
  "homepage": "https://github.com/christianbraghette/freesignal-socketio#readme",
6
6
  "bugs": {