hackchat-engine 1.1.13 → 1.1.15

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/Client.js CHANGED
@@ -442,6 +442,17 @@ class Client extends EventEmitter {
442
442
 
443
443
  this.ws.send(payload);
444
444
  }
445
+
446
+ /**
447
+ * Unsubscribe from a channel
448
+ * @param {string} channel The channel to leave
449
+ */
450
+ leave(channel) {
451
+ this.ws.send({
452
+ cmd: OPCodes.LEAVE,
453
+ channel: channel || this.channel, // @todo Multichannel
454
+ });
455
+ }
445
456
  }
446
457
 
447
458
  export default Client;
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  "lintfix": "eslint --fix --ignore-path .gitignore .",
60
60
  "test": "echo \"Error: no test specified\" && exit 1"
61
61
  },
62
- "version": "1.1.13"
62
+ "version": "1.1.15"
63
63
  }
@@ -21,28 +21,10 @@ class SessionStruct {
21
21
  */
22
22
  setup(data) {
23
23
  /**
24
- * Current channel count
25
- * @type {number}
26
- */
27
- this.channelCount = data.chans;
28
-
29
- /**
30
- * Available public channels and their user count
24
+ * Currently connected channels
31
25
  * @type {object}
32
26
  */
33
- this.publicChannels = data.public;
34
-
35
- /**
36
- * Current session id
37
- * @type {string}
38
- */
39
- this.sessionID = data.sessionID;
40
-
41
- /**
42
- * Current channel count
43
- * @type {number}
44
- */
45
- this.userCount = data.users;
27
+ this.channels = data.channels;
46
28
 
47
29
  /**
48
30
  * Was this a new or renewed session
@@ -50,13 +32,11 @@ class SessionStruct {
50
32
  */
51
33
  this.restored = data.restored;
52
34
 
53
- // add non-standard properties
54
- const dataKeys = Object.keys(data);
55
- for (let i = 0, j = dataKeys.length; i < j; i += 1) {
56
- if (dataKeys[i] !== 'cmd' && dataKeys[i] !== 'time') {
57
- this[dataKeys[i]] = data[dataKeys[i]];
58
- }
59
- }
35
+ /**
36
+ * The new token
37
+ * @type {string}
38
+ */
39
+ this.token = data.token;
60
40
  }
61
41
  }
62
42
 
package/util/Constants.js CHANGED
@@ -60,6 +60,7 @@ export const Status = {
60
60
  export const OPCodes = {
61
61
  SESSION: 'session',
62
62
  JOIN: 'join',
63
+ LEAVE: 'leave',
63
64
  CHAT: 'chat',
64
65
  INVITE: 'invite',
65
66
  CHANGE_NICK: 'changenick',
@@ -86,7 +86,7 @@ class SocketHandler extends EventEmitter {
86
86
  * Store new client session id when assigned
87
87
  */
88
88
  this.client.on(Events.SESSION, (data) => {
89
- this.sessionID = data.sessionID;
89
+ this.sessionID = data.token;
90
90
  });
91
91
 
92
92
  // Initiate connection