@eleven-am/pondsocket 0.1.67 → 0.1.69

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/README.md +7 -5
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -116,9 +116,13 @@ const message = "Hello, PondSocket!";
116
116
  channel.broadcast('message', { text: message });
117
117
 
118
118
  // Handle received messages
119
- channel.onMessage((event, message) => {
119
+ // Certain methods in the channel instance returns a subscription function, which can be used to unsubscribe from the event
120
+ const subscription = channel.onMessage((event, message) => {
120
121
  console.log(`Received message from server: ${message.text}`);
121
122
  });
123
+
124
+ // Unsubscribe from the event
125
+ subscription();
122
126
  ```
123
127
 
124
128
  The client will now connect to the server, and the server will receive the necessary headers automatically, including any authentication tokens or cookies, as required by the browser.
@@ -257,8 +261,8 @@ profanityChannel.onEvent('presence/:presence', (req, res) => {
257
261
  });
258
262
  });
259
263
 
260
- profanityChannel.onLeave((req, res) => {
261
- const { username } = req.user.assigns;
264
+ profanityChannel.onLeave((event) => {
265
+ const { username } = event.assigns;
262
266
 
263
267
  // When a user leaves the channel, PondSocket will automatically remove the user from the presence list and inform other users in the channel
264
268
 
@@ -274,8 +278,6 @@ pond.listen(3000, () => {
274
278
 
275
279
  ## API Documentation
276
280
 
277
- Apologies for the confusion. Let me remove "Class" from the title of each section:
278
-
279
281
  ### PondSocket
280
282
 
281
283
  The `PondSocket` class is the core class that represents the socket server.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.67",
3
+ "version": "0.1.69",
4
4
  "description": "PondSocket is a fast simple socket server",
5
5
  "keywords": [
6
6
  "socket",
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "author": "Roy OSSAI",
24
24
  "license": "GPL-3.0",
25
- "main": "dist/index.js",
26
- "types": "dist/index.d.ts",
25
+ "main": "index.js",
26
+ "types": "index.d.ts",
27
27
  "repository": {
28
28
  "type": "git",
29
29
  "url": "git+https://github.com/Eleven-am/pondSocket.git"