@reactoo/watchtogether-sdk-js 2.7.33 → 2.7.34

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.7.33",
3
+ "version": "2.7.34",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -26,46 +26,6 @@ class Iot {
26
26
  this.log = console.log.bind(console);
27
27
  }
28
28
 
29
- onConnect() {
30
- this.connectionActive = true;
31
- this.emit('connect');
32
- }
33
- onClosed(error) {
34
- this.connectionActive = false;
35
- this.emit('closed', error);
36
- }
37
-
38
- onDisconnect() {
39
- this.connectionActive = false;
40
- this.emit('disconnect');
41
- }
42
- onError(error) {
43
- this.connectionActive = false;
44
- this.emit('error', error);
45
- }
46
-
47
- onInterrupt(error) {
48
- this.connectionActive = false;
49
- this.emit('interrupt', error);
50
- }
51
- onResume(r) {
52
- this.connectionActive = true;
53
- this.emit('resume', r);
54
- }
55
-
56
- onMessage(topic, payload) {
57
- this.handleMessage(topic, new Uint8Array(payload));
58
- }
59
- onConnectionSuccess(r) {
60
- this.connectionActive = true;
61
- this.emit('connection_success', r);
62
- }
63
- onConnectionFailure(error) {
64
- this.connectionActive = false;
65
- this.emit('connection_failure', error);
66
- }
67
-
68
-
69
29
  connect(apiMqttUrl, apiMqttClientId, region, accessKeyId, secretAccessKey, sessionToken, expiration) {
70
30
  this.log('iot connect called, we disconnect first just to be sure');
71
31
  return this.disconnect()
@@ -88,15 +48,50 @@ class Iot {
88
48
 
89
49
  const client = new mqtt.MqttClient();
90
50
  this.connection = client.new_connection(config);
91
- this.connection.on('connect', this.onConnect, this);
92
- this.connection.on('closed', this.onClosed, this);
93
- this.connection.on('disconnect', this.onDisconnect, this);
94
- this.connection.on('error', this.onError, this);
95
- this.connection.on('interrupt', this.onInterrupt, this);
96
- this.connection.on('resume', this.onResume, this);
97
- this.connection.on('message', this.onMessage, this);
98
- this.connection.on('connection_success', this.onConnectionSuccess, this);
99
- this.connection.on('connection_failure', this.onConnectionFailure, this);
51
+
52
+ this.connection.on('connect', () => {
53
+ this.connectionActive = true;
54
+ this.emit('connect');
55
+ });
56
+
57
+ this.connection.on('closed', (error) => {
58
+ this.connectionActive = false;
59
+ this.emit('closed', error);
60
+ });
61
+
62
+ this.connection.on('disconnect', () => {
63
+ this.connectionActive = false;
64
+ this.emit('disconnect');
65
+ });
66
+
67
+ this.connection.on('error', (error) => {
68
+ this.connectionActive = false;
69
+ this.emit('error', error);
70
+ });
71
+
72
+ this.connection.on('interrupt', (error) => {
73
+ this.connectionActive = false;
74
+ this.emit('interrupt', error);
75
+ });
76
+
77
+ this.connection.on('resume', (error) => {
78
+ this.connectionActive = true;
79
+ this.emit('resume', error);
80
+ });
81
+
82
+ this.connection.on('message', (topic, payload) => {
83
+ this.handleMessage(topic, new Uint8Array(payload));
84
+ });
85
+
86
+ this.connection.on('connection_success', (error) => {
87
+ this.connectionActive = true;
88
+ this.emit('connection_success', error);
89
+ });
90
+
91
+ this.connection.on('connection_failure', (error) => {
92
+ this.connectionActive = false;
93
+ this.emit('connection_failure', error);
94
+ });
100
95
 
101
96
  return this.connection.connect()
102
97
  .then(() => {