@eleven-am/pondsocket 0.1.68 → 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.
- package/README.md +7 -5
- package/package.json +1 -1
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
|
|
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((
|
|
261
|
-
const { username } =
|
|
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.
|